summaryrefslogtreecommitdiff
path: root/src/IntPatch/IntPatch_PrmPrmIntersection_T3Bits.cxx
blob: ec18e3f17adbe803cad9133492350d9144923e3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// File:      IntPatch_PrmPrmIntersection_T3Bits.cxx
// Created:   Thu Dec 16 16:34:03 1999
// Author:    Atelier CAS2000
// Copyright: OPEN CASCADE 1999

#include <IntPatch_PrmPrmIntersection_T3Bits.ixx>

IntPatch_PrmPrmIntersection_T3Bits::IntPatch_PrmPrmIntersection_T3Bits(const Standard_Integer size)
{
  //-- ex: size=4  -> 4**3 = 64 bits -> 2 mots 32bits
  Standard_Integer nb = (size*size*size)>>5;
  Isize = nb;
  p = new Standard_Integer [nb];
  do { ((Standard_Integer *) p)[--nb]=0; } while(nb);
}

void IntPatch_PrmPrmIntersection_T3Bits::Destroy()
{
  if(p) { delete[] ((Standard_Integer*)p); p=NULL; }
}

void IntPatch_PrmPrmIntersection_T3Bits::ResetAnd()
{
  //ind = 0;
}

Standard_Integer IntPatch_PrmPrmIntersection_T3Bits::And(IntPatch_PrmPrmIntersection_T3Bits& Oth,
                                                         Standard_Integer& indice)
{
  int k=indice>>5;
  while(k<Isize)
  {
    Standard_Integer r=((Standard_Integer *) p)[k] & ((Standard_Integer *) Oth.p)[k];
    if(r)
    {
      unsigned long int c=0;
      do
      {
        if(r&1)
        {
          const Standard_Integer op = (k<<5)|(c);
          Raz(op);
          Oth.Raz(op);
          indice = op;
          return(1);
        }
        c++;
        r>>=1;
      }
      while(c<32);
    }
    k++;
  }
  return(0);
}