1 // Created on: 1992-11-24
2 // Created by: Didier PIFFAULT
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 #include <Bnd_BoundSortBox.ixx>
23 #include <Standard_NullValue.hxx>
24 #include <Standard_MultiplyDefined.hxx>
25 #include <Bnd_Array1OfBox.hxx>
26 #include <TColStd_ListIteratorOfListOfInteger.hxx>
27 #include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
29 //#if defined(WNT) || defined(LIN)
33 //-- ================================================================================
37 //-- Initialisation: Bounding box BE
38 //-- List of boxes Bi (Bi in BE)
40 //-- Compare(b) returns the list of Boxes Bi touched by b
43 //-- General principle:
45 //-- 1) Discretize box BE into N*N*N voxels
46 //-- Each box Bi touches a certain number of voxels
47 //-- Bi touches { Vijk with i0<=i<=i1 ... k0<=k<=k1 }
48 //-- 2) Project on each axis X,Y,Z boxes Bi
49 //-- to get the following structures :
53 //-- box i1 touches voxels { Vijk with 1<=i<=N-1 ... }
54 //-- box i2 touches voxels { Vijk with 2<=i<=3 ... }
55 //-- box i3 touches voxels { Vijk with 1<=i<=2 ... }
58 //-- X[.] | 1 2 3 4 .... N-1 N
59 //-- -----|-------------------------------------
65 //-- Produce the same thing for axes Y and Z
67 //-- Obtain 3 tables (X,Y,Z) of lists of integers (indexes of boxes)
69 //-- 3) To find boxes contacting with box bt
70 //-- a) Find voxels touched by bt -> i0bt,i1bt ... k0bt,k1bt
71 //-- b) Find in list Z the boxes present in cases Z[k0bt ... k1bt]
72 //-- c) Find among these boxes the ones present in cases Y[j0bt ... j1bt]
73 //-- d) and the result is the intersection of the previous result with X[i0bt ... i1bt]
76 //-- Rejection of a higher level.
78 //-- *) Preserve a table representation of bit of voxels of space BE
79 //-- that contains at least one box Bi.
80 //-- *) While box bt is texted, it is checked if this box includes in
81 //-- the table of bit at least one occupied voxel.
82 //-- If the occupied voxel is touched : no rejection
85 //-- **) Another rejection was adopted. It consists in trying to locate in
86 //-- the above structures (tables X,Y,Z and table of Bits) a box Bi which is greater than the
89 //-- The indices of these boxes are located in table ToTest, and these
90 // boxes are compared systematically with bt.
92 //-- Note : tables C replace here HArray1OfListOfInteger and other
93 //-- structures that are sufficient for data adding but slow for reading.
95 //-- Here the data is added at start (Initialize and SortBoxes) and later,
96 //-- it takes much time to parse the tables. The slowly written, byut fastly read structures
103 //=======================================================================
104 #define VERIFICATION 0
109 static long unsigned APPELREJECTION=0L;
110 static long unsigned REJECTNIV0=0L;
111 static long unsigned REJECTNIV1=0L;
112 static long unsigned NBCOMPARE=0L;
113 static long unsigned NBBOITES=0L;
114 static long unsigned NBBOITESATESTER=0L;
116 //=======================================================================
117 static Standard_Integer ComputeSize(const Standard_Integer n) {
118 if(n>40000) return(128);
119 if(n>10000) return(64);
120 if(n>1000) return(32);
121 if(n>100) return(16);
124 //=======================================================================
125 static long unsigned _P2[32] = { 1,2,4,8, 16,32,64,128, 256,512,1024,2048,
126 4096,8192,16384,32768,
127 65536,131072,262144,524288,
128 1048576,2097152,4194304,8388608,
129 16777216,33554432,67108864,134217728,
130 268435456,536870912,1073741824,2147483648U};
131 class BSB_T3Bits { //-- size is power of 2 > 4
134 Standard_Integer _DECAL;
135 Standard_Integer _DECAL2;
136 Standard_Integer _BASE;
137 Standard_Integer _BASEM1;
141 Standard_Integer ssize;
142 Standard_Real Xmin,Xmax,Ymin,Ymax,Zmin,Zmax;
145 Standard_Integer **axisX;
146 Standard_Integer **axisY;
147 Standard_Integer **axisZ;
149 Standard_Integer *ToTest;
152 BSB_T3Bits(int size);
155 //-- Part HArray1OfListOfInteger
157 void AppendAxisX(const Standard_Integer i,const Standard_Integer v);
158 void AppendAxisY(const Standard_Integer i,const Standard_Integer v);
159 void AppendAxisZ(const Standard_Integer i,const Standard_Integer v);
161 void Add(long unsigned t) { int o=t&31; int k=t>>5; p[k]|=_P2[o]; }
162 int Val(long unsigned t) { int o=t&31; int k=t>>5; return(p[k]&_P2[o]); }
163 void Raz(long unsigned t) { int o=t&31; int k=t>>5; p[k]&= ~(_P2[o]); }
165 Standard_Integer NbAxisX(const Standard_Integer i) { return(axisX[0][i]); }
166 Standard_Integer NbAxisY(const Standard_Integer i) { return(axisY[0][i]); }
167 Standard_Integer NbAxisZ(const Standard_Integer i) { return(axisZ[0][i]); }
169 inline Standard_Integer GrilleInteger(Standard_Integer ix,
171 Standard_Integer iz) {
172 Standard_Integer tz = iz<<_DECAL2;
173 Standard_Integer ty = iy<<_DECAL;
174 Standard_Integer t = ix;
179 inline void IntegerGrille(Standard_Integer t,
180 Standard_Integer &ix,
181 Standard_Integer &iy,
182 Standard_Integer &iz) {
183 ix = t & _BASEM1; t>>=_DECAL;
184 iy = t & _BASEM1; t>>=_DECAL;
188 //=======================================================================
189 BSB_T3Bits::~BSB_T3Bits() {
190 if(p) { delete [] p; p=0; }
192 printf("\n BASE:%d\n",_BASE);
194 for(Standard_Integer i=0; i<=ssize; i++) {
195 if(axisX[i]) { delete [] axisX[i]; axisX[i]=0; }
196 if(axisY[i]) { delete [] axisY[i]; axisY[i]=0; }
197 if(axisZ[i]) { delete [] axisZ[i]; axisZ[i]=0; }
199 free(axisX); axisX=0;
200 free(axisY); axisY=0;
201 free(axisZ); axisZ=0;
202 if(ToTest) { delete [] ToTest; ToTest=0; }
204 //=======================================================================
205 BSB_T3Bits::BSB_T3Bits(int size) {
207 case 128: { _DECAL=7; _DECAL2=14; _BASE=128; _BASEM1=127; break; }
208 case 64: { _DECAL=6; _DECAL2=12; _BASE= 64; _BASEM1= 63; break; }
209 case 32: { _DECAL=5; _DECAL2=10; _BASE= 32; _BASEM1= 31; break; }
210 case 16: { _DECAL=4; _DECAL2= 8; _BASE= 16; _BASEM1= 15; break; }
211 default : { _DECAL=3; _DECAL2= 6; _BASE= 8; _BASEM1= 7; break; }
214 long unsigned nb = (size*size*size)>>5;
217 p = new long unsigned [nb];
218 do { p[--nb]=0; } while(nb);
220 axisX = (Standard_Integer **) malloc((size+1)*sizeof(Standard_Integer *));
221 axisY = (Standard_Integer **) malloc((size+1)*sizeof(Standard_Integer *));
222 axisZ = (Standard_Integer **) malloc((size+1)*sizeof(Standard_Integer *));
224 axisX[0]=new Standard_Integer [_BASE+1];
225 axisY[0]=new Standard_Integer [_BASE+1];
226 axisZ[0]=new Standard_Integer [_BASE+1];
228 for( i=0; i<(_BASE+1); i++) {
234 for(i=1; i<=size; i++) {
235 axisX[i] = new Standard_Integer[DIMAXIS];
236 axisY[i] = new Standard_Integer[DIMAXIS];
237 axisZ[i] = new Standard_Integer[DIMAXIS];
241 axisX[i][1]=axisY[i][1]=axisZ[i][1]=-1;
245 //=======================================================================
246 void BSB_T3Bits::AppendAxisZ(const Standard_Integer i,
247 const Standard_Integer v) {
248 Standard_Integer n = axisZ[0][i];
250 if(n<axisZ[i][0]) { axisZ[i][n]=v; }
252 Standard_Integer s=axisZ[i][0];
253 Standard_Integer *nt = new Standard_Integer [s+s];
255 for(Standard_Integer j=1;j<s;j++) {
264 //=======================================================================
265 void BSB_T3Bits::AppendAxisY(const Standard_Integer i,
266 const Standard_Integer v) {
267 Standard_Integer n = axisY[0][i];
269 if(n<axisY[i][0]) { axisY[i][n]=v; }
271 Standard_Integer s=axisY[i][0];
272 Standard_Integer *nt = new Standard_Integer [s+s];
274 for(Standard_Integer j=1;j<s;j++) {
283 //=======================================================================
284 void BSB_T3Bits::AppendAxisX(const Standard_Integer i,
285 const Standard_Integer v) {
286 Standard_Integer n = axisX[0][i];
289 if(n<axisX[i][0]) { axisX[i][n]=v; }
291 //-- it is required to extend
292 Standard_Integer s=axisX[i][0];
293 Standard_Integer *nt = new Standard_Integer [s+s];
295 for(Standard_Integer j=1;j<s;j++) {
304 //=======================================================================
305 //=======================================================================
306 //function : Bnd_BoundSortBox
308 //=======================================================================
309 Bnd_BoundSortBox::Bnd_BoundSortBox()
310 : discrX(0), discrY(0), discrZ(0)
314 NBCOMPARE=0L; NBBOITES=0L; NBBOITESATESTER=0L;
315 APPELREJECTION=0L; REJECTNIV0=0L; REJECTNIV1=0L;
318 //=======================================================================
319 //function : Initialize
321 //=======================================================================
323 void Bnd_BoundSortBox::Initialize(const Bnd_Box& CompleteBox,
324 const Handle(Bnd_HArray1OfBox)& SetOfBox)
327 myBndComponents=SetOfBox;
328 const Bnd_Array1OfBox & taBox=myBndComponents->Array1();
329 discrX=discrY=discrZ=ComputeSize(taBox.Upper()-taBox.Lower());
330 Standard_Real Xmax, Ymax, Zmax;
331 if(CompleteBox.IsVoid())
333 CompleteBox.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
334 deltaX = (Xmax-Xmin == 0. ? 0. : discrX/(Xmax-Xmin));
335 deltaY = (Ymax-Ymin == 0. ? 0. : discrY/(Ymax-Ymin));
336 deltaZ = (Zmax-Zmin == 0. ? 0. : discrZ/(Zmax-Zmin));
339 //=======================================================================
340 //function : Initialize
342 //=======================================================================
343 void Bnd_BoundSortBox::Initialize(const Handle(Bnd_HArray1OfBox)& SetOfBox)
345 myBndComponents=SetOfBox;
346 const Bnd_Array1OfBox & taBox=myBndComponents->Array1();
347 Standard_Integer i0,i1;
350 discrX=discrY=discrZ=ComputeSize(i1-i0);
351 Standard_Integer labox;
352 for (labox=i0; labox<=i1; labox++) {
353 if (!taBox(labox).IsVoid()) {
354 myBox.Add(taBox(labox));
357 Standard_Real Xmax, Ymax, Zmax;
360 myBox.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
361 deltaX = (Xmax-Xmin == 0. ? 0. : discrX/(Xmax-Xmin));
362 deltaY = (Ymax-Ymin == 0. ? 0. : discrY/(Ymax-Ymin));
363 deltaZ = (Zmax-Zmin == 0. ? 0. : discrZ/(Zmax-Zmin));
366 //=======================================================================
367 //function : SortBoxes
369 //=======================================================================
370 void Bnd_BoundSortBox::SortBoxes()
372 Standard_Integer labox;
373 Standard_Integer lacaseX, firstcaseX, lastcaseX;
374 Standard_Integer lacaseY, firstcaseY, lastcaseY;
375 Standard_Integer lacaseZ, firstcaseZ, lastcaseZ;
376 Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
377 const Bnd_Array1OfBox & taBox=myBndComponents->Array1();
378 Standard_Integer i0=taBox.Lower();
379 Standard_Integer i1=taBox.Upper();
382 BSB_T3Bits* _Map = (BSB_T3Bits *)TabBits;
385 Map = new BSB_T3Bits(discrX);
386 TabBits = (void *)Map;
388 Standard_Integer s=i1-i0;
390 Map->ToTest = new Standard_Integer [s];
391 for(Standard_Integer i=0; i<s; i++) {
395 Standard_Real _Xmax,_Xmin,_Ymax,_Ymin,_Zmin,_Zmax;
396 myBox.Get(_Xmin,_Ymin,_Zmin,_Xmax,_Ymax,_Zmax);
397 Map->Xmax=_Xmax; Map->Ymax=_Ymax; Map->Zmax=_Zmax;
398 Map->Xmin=_Xmin; Map->Ymin=_Ymin; Map->Zmin=_Zmin;
399 for (labox=i0; labox<=i1; labox++) {
400 if (!taBox(labox).IsVoid()) {
401 taBox(labox).Get(xmin, ymin, zmin, xmax, ymax, zmax);
402 if(xmin>Xmin) firstcaseX=(Standard_Integer )((xmin-Xmin)*deltaX)-1; else firstcaseX=1;
403 if(ymin>Ymin) firstcaseY=(Standard_Integer )((ymin-Ymin)*deltaY)-1; else firstcaseY=1;
404 if(zmin>Zmin) firstcaseZ=(Standard_Integer )((zmin-Zmin)*deltaZ)-1; else firstcaseZ=1;
405 if(xmax<_Xmax) lastcaseX=(Standard_Integer )((xmax-Xmin)*deltaX)+1; else lastcaseX=discrX;
406 if(ymax<_Ymax) lastcaseY=(Standard_Integer )((ymax-Ymin)*deltaY)+1; else lastcaseY=discrY;
407 if(zmax<_Zmax) lastcaseZ=(Standard_Integer )((zmax-Zmin)*deltaZ)+1; else lastcaseZ=discrZ;
408 if(firstcaseX<1) firstcaseX=1; else if(firstcaseX>discrX) firstcaseX=discrX;
409 if(firstcaseY<1) firstcaseY=1; else if(firstcaseY>discrY) firstcaseY=discrY;
410 if(firstcaseZ<1) firstcaseZ=1; else if(firstcaseZ>discrZ) firstcaseZ=discrZ;
412 if(lastcaseX<1) lastcaseX=1; else if(lastcaseX>discrX) lastcaseX=discrX;
413 if(lastcaseY<1) lastcaseY=1; else if(lastcaseY>discrY) lastcaseY=discrY;
414 if(lastcaseZ<1) lastcaseZ=1; else if(lastcaseZ>discrZ) lastcaseZ=discrZ;
416 Standard_Integer n = (lastcaseX-firstcaseX);
417 if(n>(lastcaseY-firstcaseY)) n=lastcaseY-firstcaseY;
418 if(n>(lastcaseZ-firstcaseZ)) n=lastcaseZ-firstcaseZ;
427 for(Standard_Integer i=0; i<(i1-i0); i++) {
428 if(Map->ToTest[i]<i0) {
429 Map->ToTest[i]=labox;
435 for (lacaseX=firstcaseX; lacaseX<=lastcaseX; lacaseX++) {
436 Map->AppendAxisX(lacaseX,labox);
438 for (lacaseY=firstcaseY; lacaseY<=lastcaseY; lacaseY++) {
439 Map->AppendAxisY(lacaseY,labox);
441 for (lacaseZ=firstcaseZ; lacaseZ<=lastcaseZ; lacaseZ++) {
442 Map->AppendAxisZ(lacaseZ,labox);
444 //------------------------------------------------------------
445 //-- fill table with bits
448 for (lacaseX=firstcaseX; lacaseX<=lastcaseX; lacaseX++) {
449 for (lacaseY=firstcaseY; lacaseY<=lastcaseY; lacaseY++) {
450 for (lacaseZ=firstcaseZ; lacaseZ<=lastcaseZ; lacaseZ++) {
451 long unsigned t=Map->GrilleInteger(lacaseX-1,lacaseY-1,lacaseZ-1);
461 //=======================================================================
462 //function : Initialize
464 //=======================================================================
465 void Bnd_BoundSortBox::Initialize(const Bnd_Box& CompleteBox,
466 const Standard_Integer nbComponents)
468 Standard_NullValue_Raise_if (nbComponents <=0, "BoundSortBox nul!");
470 myBndComponents=new Bnd_HArray1OfBox(1,nbComponents);
472 //***>>> JCD - 04.08.2000 - Array initialization is missing...
474 myBndComponents->Init( emptyBox );
477 discrX=discrY=discrZ=ComputeSize(nbComponents);
478 Standard_Real Xmax, Ymax, Zmax;
480 if(CompleteBox.IsVoid())
482 CompleteBox.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
483 myBox.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
484 deltaX = (Xmax-Xmin == 0. ? 0. : discrX/(Xmax-Xmin));
485 deltaY = (Ymax-Ymin == 0. ? 0. : discrY/(Ymax-Ymin));
486 deltaZ = (Zmax-Zmin == 0. ? 0. : discrZ/(Zmax-Zmin));
488 BSB_T3Bits* _Map = (BSB_T3Bits *)TabBits;
493 Map = new BSB_T3Bits(discrX);
494 TabBits = (void *)Map;
496 //=======================================================================
499 //=======================================================================
500 void Bnd_BoundSortBox::Add(const Bnd_Box& theBox,
501 const Standard_Integer boxIndex)
503 Standard_MultiplyDefined_Raise_if (!(myBndComponents->Value(boxIndex).IsVoid()), " This box is already defined !");
504 if (!theBox.IsVoid()) {
505 Standard_Integer i0=myBndComponents->Lower();
506 Standard_Integer i1=myBndComponents->Upper();
507 Standard_Integer theGapX, firstGapX , lastGapX;
508 Standard_Integer theGapY, firstGapY , lastGapY;
509 Standard_Integer theGapZ, firstGapZ , lastGapZ;
510 Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
511 myBndComponents->SetValue(boxIndex, theBox);
512 theBox.Get(xmin, ymin, zmin, xmax, ymax, zmax);
513 BSB_T3Bits* Map = (BSB_T3Bits *)TabBits;
515 Standard_Integer s=i1-i0;
517 Map->ToTest = new Standard_Integer [s];
518 for(Standard_Integer i=0; i<s; i++) {
522 Standard_Real _Xmax,_Ymax,_Zmax;
523 _Xmax=Map->Xmax; _Ymax=Map->Ymax; _Zmax=Map->Zmax;
524 if(xmin>Xmin) firstGapX=(Standard_Integer )((xmin-Xmin)*deltaX)-1; else firstGapX=1;
525 if(ymin>Ymin) firstGapY=(Standard_Integer )((ymin-Ymin)*deltaY)-1; else firstGapY=1;
526 if(zmin>Zmin) firstGapZ=(Standard_Integer ) ((zmin-Zmin)*deltaZ)-1; else firstGapZ=1;
527 if(xmax<_Xmax) lastGapX=(Standard_Integer )((xmax-Xmin)*deltaX)+1; else lastGapX=discrX;
528 if(ymax<_Ymax) lastGapY=(Standard_Integer )((ymax-Ymin)*deltaY)+1; else lastGapY=discrY;
529 if(zmax<_Zmax) lastGapZ=(Standard_Integer )((zmax-Zmin)*deltaZ)+1; else lastGapZ=discrZ;
530 if(firstGapX<1) firstGapX=1; else if(firstGapX>discrX) firstGapX=discrX;
531 if(firstGapY<1) firstGapY=1; else if(firstGapY>discrY) firstGapY=discrY;
532 if(firstGapZ<1) firstGapZ=1; else if(firstGapZ>discrZ) firstGapZ=discrZ;
534 if(lastGapX<1) lastGapX=1; else if(lastGapX>discrX) lastGapX=discrX;
535 if(lastGapY<1) lastGapY=1; else if(lastGapY>discrY) lastGapY=discrY;
536 if(lastGapZ<1) lastGapZ=1; else if(lastGapZ>discrZ) lastGapZ=discrZ;
537 Standard_Integer n = (lastGapX-firstGapX);
538 if(n>(lastGapY-firstGapY)) n=lastGapY-firstGapY;
539 if(n>(lastGapZ-firstGapZ)) n=lastGapZ-firstGapZ;
548 for(Standard_Integer i=0; i<(i1-i0); i++) {
549 if(Map->ToTest[i]<i0) {
550 Map->ToTest[i]=boxIndex;
555 for (theGapY=firstGapY; theGapY<=lastGapY; theGapY++) {
556 Map->AppendAxisY(theGapY,boxIndex);
558 for (theGapX=firstGapX; theGapX<=lastGapX; theGapX++) {
559 Map->AppendAxisX(theGapX,boxIndex);
561 for (theGapZ=firstGapZ; theGapZ<=lastGapZ; theGapZ++) {
562 Map->AppendAxisZ(theGapZ,boxIndex);
564 //------------------------------------------------------------
565 //-- fill table with bits
568 Map=(BSB_T3Bits *)TabBits;
569 for (theGapX=firstGapX; theGapX<=lastGapX; theGapX++) {
570 for (theGapY=firstGapY; theGapY<=lastGapY; theGapY++) {
571 for (theGapZ=firstGapZ; theGapZ<=lastGapZ; theGapZ++) {
572 long unsigned t=Map->GrilleInteger(theGapX-1,theGapY-1,theGapZ-1);
580 //=======================================================================
582 static void VerifCompare(const TColStd_ListOfInteger& lastResult,
583 const Bnd_Box& theBox,
584 const Bnd_Array1OfBox& taBox) {
585 static int Verif = 1;
589 Standard_Integer i0,i1;
592 char * qwe=new char [i1+1]; //-- $$$$$$$ ATTENTION IF I0 < 0
593 for( i=i0; i<=i1; i++) qwe[i]='\0';
594 TColStd_ListIteratorOfListOfInteger theList(lastResult);
595 for (; theList.More(); theList.Next()) {
596 qwe[theList.Value()]=(char)1;
598 Standard_Integer labox;
599 for (labox=i0; labox<=i1; labox++) {
600 if (!taBox(labox).IsOut(theBox)) {
604 for(i=i0;i<=i1;i++) {
606 printf("\nPb with box: %d ",i);
609 printf("\n false rejection by %d \n",i);
616 //=======================================================================
619 //=======================================================================
620 const TColStd_ListOfInteger& Bnd_BoundSortBox::Compare (const Bnd_Box& theBox)
623 Standard_Integer lacase ;
628 if (theBox.IsVoid()) return lastResult;
629 if (theBox.IsOut(myBox)) {
635 const Bnd_Array1OfBox& taBox=myBndComponents->Array1();
636 //-- Rejection with the table of bits
637 Standard_Boolean touch = Standard_True;
638 touch = Standard_False;
639 Standard_Real _Xmin,_Ymin,_Zmin,_Xmax,_Ymax,_Zmax;
640 BSB_T3Bits* Map = (BSB_T3Bits *)TabBits;
641 Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
642 _Xmax=Map->Xmax; _Ymax=Map->Ymax; _Zmax=Map->Zmax;
643 _Xmin=Map->Xmin; _Ymin=Map->Ymin; _Zmin=Map->Zmin;
644 theBox.Get(xmin, ymin, zmin, xmax, ymax, zmax);
645 Standard_Integer i0,i1,j0,j1,k0,k1;
646 if(xmin>Xmin) i0=(Standard_Integer )((xmin-Xmin)*deltaX)-1; else i0=1;
647 if(ymin>Ymin) j0=(Standard_Integer )((ymin-Ymin)*deltaY)-1; else j0=1;
648 if(zmin>Zmin) k0=(Standard_Integer )((zmin-Zmin)*deltaZ)-1; else k0=1;
649 if(xmax<_Xmax) i1=(Standard_Integer )((xmax-Xmin)*deltaX)+1; else i1=discrX;
650 if(ymax<_Ymax) j1=(Standard_Integer )((ymax-Ymin)*deltaY)+1; else j1=discrY;
651 if(zmax<_Zmax) k1=(Standard_Integer )((zmax-Zmin)*deltaZ)+1; else k1=discrZ;
652 if(i0<1) i0=1; else if(i0>discrX) i0=discrX;
653 if(j0<1) j0=1; else if(j0>discrY) j0=discrY;
654 if(k0<1) k0=1; else if(k0>discrZ) k0=discrZ;
656 if(i1<1) i1=1; else if(i1>discrX) i1=discrX;
657 if(j1<1) j1=1; else if(j1>discrY) j1=discrY;
658 if(k1<1) k1=1; else if(k1>discrZ) k1=discrZ;
659 i0--; j0--; k0--; i1--; j1--; k1--;
660 for(Standard_Integer i=i0; touch==Standard_False && i<=i1;i++) {
661 for(Standard_Integer j=j0; touch==Standard_False && j<=j1;j++) {
662 for(Standard_Integer k=k0; touch==Standard_False && k<=k1;k++) {
663 long unsigned t=Map->GrilleInteger(i,j,k);
665 touch = Standard_True;
670 //-- processing of systematically tested boxes
672 Standard_Integer l0 = taBox.Lower();
673 Standard_Integer l1 = taBox.Upper();
675 for(Standard_Integer l=0; Map->ToTest[l]>=l0 && l<(l1-l0); l++) {
676 if(Map->ToTest[l]>=l0) {
677 if (!taBox(Map->ToTest[l]).IsOut(theBox)){
678 lastResult.Append(Map->ToTest[l]);
683 if(touch == Standard_False) {
688 VerifCompare(lastResult,theBox,taBox);
692 //------------------------
693 //-- classic processing --
694 //------------------------
695 i0++; i1++; j0++; j1++; k0++; k1++;
698 Standard_Integer cardY=0;
699 for (lacase=j0; lacase<=j1; lacase++) {
700 Standard_Integer nby=Map->NbAxisY(lacase);
703 Crible.Bind(Map->axisY[lacase][nby], 4);
709 VerifCompare(lastResult,theBox,taBox);
713 Standard_Integer cardZ=0;
714 for (lacase=k0; lacase<=k1; lacase++) {
715 Standard_Integer nbz=Map->NbAxisZ(lacase);
718 if (Crible.IsBound(Map->axisZ[lacase][nbz])) {
719 Crible.Bind(Map->axisZ[lacase][nbz], 6);
726 VerifCompare(lastResult,theBox,taBox);
730 for (lacase=i0; lacase<=i1; lacase++) {
731 Standard_Integer nbx = Map->NbAxisX(lacase);
733 Standard_Integer x=Map->axisX[lacase][nbx];
734 if (Crible.IsBound(x)) {
735 if (Crible(x)==theFound) {
737 if (!taBox(x).IsOut(theBox)){
738 lastResult.Append(x);
746 VerifCompare(lastResult,theBox,taBox);
750 //=======================================================================
753 //=======================================================================
755 void Bnd_BoundSortBox::Dump() const
757 //=======================================================================
760 //=======================================================================
761 const TColStd_ListOfInteger& Bnd_BoundSortBox::Compare(const gp_Pln& thePlane)
766 const Bnd_Array1OfBox& boxes = myBndComponents->Array1();
767 for (i = boxes.Lower(); i <= boxes.Upper(); i++) {
768 if (!boxes(i).IsOut(thePlane))
769 lastResult.Append(i);
773 //=======================================================================
774 void Bnd_BoundSortBox::Destroy() {
776 printf("\nDESTROY NBCOMPARE:%lu REJECTNIV0:%lu REJECTIONSOK=%lu NBBOITES:%lu NBBOITESATESTER:%lu\n",
777 NBCOMPARE,REJECTNIV0,REJECTNIV1,NBBOITES,NBBOITESATESTER);
779 BSB_T3Bits* Map = (BSB_T3Bits *)TabBits;
785 //=======================================================================