Esempio n. 1
0
            private bool isWithin(Bspt.Tuple t)
            {
                double dist2;
                double distT;

                distT = t.getDimValue(0) - centerValues[0];
                if (tHemisphere && distT < 0)
                {
                    return(false);
                }
                dist2 = distT * distT;
                if (dist2 > distance2)
                {
                    return(false);
                }
                for (int dim = bspt.dimMax; --dim > 0;)
                {
                    distT  = t.getDimValue(dim) - centerValues[dim];
                    dist2 += distT * distT;
                    if (dist2 > distance2)
                    {
                        return(false);
                    }
                }
                this.foundDistance2_Renamed_Field = dist2;
                return(true);
            }
Esempio n. 2
0
 public EnumerateSphere(Bspt bspt, Bspt.Tuple center, double distance, bool tHemisphere)
 {
     this.bspt        = bspt;
     this.distance    = distance;
     this.distance2   = distance * distance;
     this.center      = center;
     this.tHemisphere = tHemisphere;
     centerValues     = new double[bspt.dimMax];
     for (int dim = bspt.dimMax; --dim >= 0;)
     {
         centerValues[dim] = center.getDimValue(dim);
     }
     stack = new Node[Bspt.stackDepth];
     sp    = 0;
     Bspt.Element ele = bspt.eleRoot;
     while (ele is Node)
     {
         Node node = (Node)ele;
         if (center.getDimValue(node.dim) - distance <= node.splitValue)
         {
             if (sp == Bspt.stackDepth)
             {
                 System.Console.Out.WriteLine("Bspt.EnumerateSphere tree stack overflow");
             }
             stack[sp++] = node;
             ele         = node.eleLE;
         }
         else
         {
             ele = node.eleGE;
         }
     }
     leaf = (Leaf)ele;
     i    = 0;
 }
Esempio n. 3
0
            public Leaf(Leaf leaf, int dim, double splitValue)
                : this()
            {
                for (int i = Bspt.leafCount; --i >= 0;)
                {
                    Bspt.Tuple tuple         = leaf.tuples[i];
                    double     value_Renamed = tuple.getDimValue(dim);
                    if (value_Renamed > splitValue || (value_Renamed == splitValue && ((i & 1) == 1)))
                    {
                        leaf.tuples[i]  = null;
                        tuples[count++] = tuple;
                    }
                }
                int dest = 0;

                for (int src = 0; src < Bspt.leafCount; ++src)
                {
                    if (leaf.tuples[src] != null)
                    {
                        leaf.tuples[dest++] = leaf.tuples[src];
                    }
                }
                leaf.count = dest;
                if (count == 0)
                {
                    tuples[Bspt.leafCount] = null; // explode
                }
            }
Esempio n. 4
0
            public EnumerateNear(Bspt bspt, Bspt.Tuple center, double distance)
            {
                this.distance = distance;
                this.center   = center;

                stack = new Node[Bspt.stackDepth];
                sp    = 0;
                Bspt.Element ele = bspt.eleRoot;
                while (ele is Node)
                {
                    Node node = (Node)ele;
                    if (center.getDimValue(node.dim) - distance <= node.splitValue)
                    {
                        if (sp == Bspt.stackDepth)
                        {
                            System.Console.Out.WriteLine("Bspt.EnumerateNear tree stack overflow");
                        }
                        stack[sp++] = node;
                        ele         = node.eleLE;
                    }
                    else
                    {
                        ele = node.eleGE;
                    }
                }
                leaf = (Leaf)ele;
                i    = 0;
            }
Esempio n. 5
0
 public bool addTuple(Bspt.Tuple tuple)
 {
     if (tuple.getDimValue(dim) < splitValue)
     {
         if (eleLE.addTuple(tuple))
         {
             return(true);
         }
         eleLE = new Node((dim + 1) % dimMax, dimMax, (Leaf)eleLE);
         return(eleLE.addTuple(tuple));
     }
     if (tuple.getDimValue(dim) > splitValue)
     {
         if (eleGE.addTuple(tuple))
         {
             return(true);
         }
         eleGE = new Node((dim + 1) % dimMax, dimMax, (Leaf)eleGE);
         return(eleGE.addTuple(tuple));
     }
     if (eleLE.LeafWithSpace)
     {
         eleLE.addTuple(tuple);
     }
     else if (eleGE.LeafWithSpace)
     {
         eleGE.addTuple(tuple);
     }
     else if (eleLE is Node)
     {
         eleLE.addTuple(tuple);
     }
     else if (eleGE is Node)
     {
         eleGE.addTuple(tuple);
     }
     else
     {
         eleLE = new Node((dim + 1) % dimMax, dimMax, (Leaf)eleLE);
         return(eleLE.addTuple(tuple));
     }
     return(true);
 }
Esempio n. 6
0
 private bool hasMoreElements()
 {
     while (true)
     {
         for (; i < leaf.count; ++i)
         {
             if (isWithin(leaf.tuples[i]))
             {
                 return(true);
             }
         }
         if (sp == 0)
         {
             return(false);
         }
         Bspt.Element ele = stack[--sp];
         while (ele is Node)
         {
             Node node = (Node)ele;
             if (center.getDimValue(node.dim) + distance < node.splitValue)
             {
                 if (sp == 0)
                 {
                     return(false);
                 }
                 ele = stack[--sp];
             }
             else
             {
                 ele = node.eleGE;
                 while (ele is Node)
                 {
                     Node nodeLeft = (Node)ele;
                     stack[sp++] = nodeLeft;
                     ele         = nodeLeft.eleLE;
                 }
             }
         }
         leaf = (Leaf)ele;
         i    = 0;
     }
 }
Esempio n. 7
0
 //UPGRADE_NOTE: The equivalent of method 'java.util.Enumeration.hasMoreElements' is not an override method. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1143'"
 public bool hasMoreElements()
 {
     if (i < leaf.count)
     {
         return(true);
     }
     if (sp == 0)
     {
         return(false);
     }
     Bspt.Element ele = stack[--sp];
     while (ele is Node)
     {
         Node node = (Node)ele;
         if (center.getDimValue(node.dim) + distance < node.splitValue)
         {
             if (sp == 0)
             {
                 return(false);
             }
             ele = stack[--sp];
         }
         else
         {
             ele = node.eleGE;
             while (ele is Node)
             {
                 Node nodeLeft = (Node)ele;
                 stack[sp++] = nodeLeft;
                 ele         = nodeLeft.eleLE;
             }
         }
     }
     leaf = (Leaf)ele;
     i    = 0;
     return(true);
 }
Esempio n. 8
0
 public EnumerateSphere(Bspt bspt, Bspt.Tuple center, double distance, bool tHemisphere)
 {
     this.bspt = bspt;
     this.distance = distance;
     this.distance2 = distance * distance;
     this.center = center;
     this.tHemisphere = tHemisphere;
     centerValues = new double[bspt.dimMax];
     for (int dim = bspt.dimMax; --dim >= 0; )
         centerValues[dim] = center.getDimValue(dim);
     stack = new Node[Bspt.stackDepth];
     sp = 0;
     Bspt.Element ele = bspt.eleRoot;
     while (ele is Node)
     {
         Node node = (Node)ele;
         if (center.getDimValue(node.dim) - distance <= node.splitValue)
         {
             if (sp == Bspt.stackDepth)
                 System.Console.Out.WriteLine("Bspt.EnumerateSphere tree stack overflow");
             stack[sp++] = node;
             ele = node.eleLE;
         }
         else
         {
             ele = node.eleGE;
         }
     }
     leaf = (Leaf)ele;
     i = 0;
 }
Esempio n. 9
0
            public EnumerateNear(Bspt bspt, Bspt.Tuple center, double distance)
            {
                this.distance = distance;
                this.center = center;

                stack = new Node[Bspt.stackDepth];
                sp = 0;
                Bspt.Element ele = bspt.eleRoot;
                while (ele is Node)
                {
                    Node node = (Node)ele;
                    if (center.getDimValue(node.dim) - distance <= node.splitValue)
                    {
                        if (sp == Bspt.stackDepth)
                            System.Console.Out.WriteLine("Bspt.EnumerateNear tree stack overflow");
                        stack[sp++] = node;
                        ele = node.eleLE;
                    }
                    else
                    {
                        ele = node.eleGE;
                    }
                }
                leaf = (Leaf)ele;
                i = 0;
            }