예제 #1
0
파일: Rectangle.cs 프로젝트: armano2/fastdb
 /// <summary>
 /// Create copy of the rectangle
 /// </summary>
 ///
 public Rectangle(Rectangle r)
 {
     this.x0 = r.x0;
     this.x1 = r.x1;
     this.y0 = r.y0;
     this.y1 = r.y1;
 }
예제 #2
0
파일: Rectangle.cs 프로젝트: armano2/fastdb
 /// <summary>
 /// Distance between two rectangles
 /// </summary>
 /// <param name="r">first rectangle</param>
 /// <param name="q">second rectangle</param>
 /// <returns>distance between two rectangles</returns>
 ///
 public static int distance(Rectangle r, Rectangle q)
 {
     if (r.overlaps(q)) {
     return 0;
     }
     int d = 0;
     if (r.x0 > q.x1) {
     d += (r.x0 - q.x1)*(r.x0 - q.x1);
     } else if (q.x0 > r.x1) {
     d += (q.x0 - r.x1)*(q.x0 - r.x1);
     }
     if (r.y0 > q.y1) {
     d += (r.y0 - q.y1)*(r.y0 - q.y1);
     } else if (q.y0 > r.y1) {
     d += (q.y0 - r.y1)*(q.y0 - r.y1);
     }
     return (int)Math.Sqrt((double)d);
 }
예제 #3
0
파일: Rectangle.cs 프로젝트: armano2/fastdb
 /// <summary>
 /// Calculate cover of two rectangles
 /// </summary>
 /// <param name="p">first rectangle</param>
 /// <param name="q">second rectangle</param>
 /// <returns>minimal rectangle containing both specified rectangles</returns>
 ///
 public static Rectangle join(Rectangle p, Rectangle q)
 {
     Rectangle res = new Rectangle(p);
     res.join(q);
     return res;
 }
예제 #4
0
파일: Rectangle.cs 프로젝트: armano2/fastdb
 /// <summary>
 /// Calculate cover of two rectangles
 /// This rectangle is changesd to be the minimal rectangle containing 
 /// original rectangle and specified rectangles
 /// </summary>
 /// <param name="r">another rectangle</param>
 ///    
 public void join(Rectangle r)
 {
     if (x0 > r.x0) {
     x0 = r.x0;
     }
     if (y0 > r.y0) {
     y0 = r.y0;
     }
     if (x1 < r.x1) {
     x1 = r.x1;
     }
     if (y1 < r.y1) {
     y1 = r.y1;
     }
 }
예제 #5
0
파일: Rectangle.cs 프로젝트: armano2/fastdb
 /// <summary>
 /// Check whether two rectngles overlap
 /// </summary>
 ///
 public bool overlaps(Rectangle r)
 {
     return x0 <= r.x1 && y0 <= r.y1 && r.x0 <= x1 && r.y0 <= y1;
 }
예제 #6
0
파일: Rectangle.cs 프로젝트: armano2/fastdb
 /// <summary>
 /// Checks whether this rectangle contains specified <code>r</code> rectangle
 /// </summary>
 ///
 public bool contains(Rectangle r)
 {
     return x0 <= r.x0 && y0 <= r.y0 && x1 >= r.x1 && y1 >= r.y1;
 }
예제 #7
0
 /// <summary>
 /// Set rectangle parameter
 /// </summary>
 /// <param name="name">name of the parameter started with <code>%</code> character</param>
 /// <param name="rect">value of the parameter</param>
 ///
 public void setRectangle(string name, Rectangle rect)
 {
     Parameter p = getParam(name);
     p.rvalue = rect;
     p.type = Connection.CLIType.cli_rectangle;
 }
예제 #8
0
 internal void putRectangle(Rectangle r)
 {
     extend(16);
     pos = packInt(buf, pos, r.x0);
     pos = packInt(buf, pos, r.y0);
     pos = packInt(buf, pos, r.x1);
     pos = packInt(buf, pos, r.y1);
 }
예제 #9
0
 internal Rectangle getRectangle()
 {
     Rectangle r = new Rectangle(unpackInt(buf, pos),
                             unpackInt(buf, pos+4),
                             unpackInt(buf, pos+8),
                             unpackInt(buf, pos+12));
     pos += 16;
     return r;
 }
예제 #10
0
 internal void writeColumnValues(ComBuffer buf, Object obj)
 {
     int i, j, n, len;
     for (i = 0, n = nColumns; i < n; i++)
     {
     switch (types[i])
     {
         case Connection.CLIType.cli_int1:
             buf.putByte((byte)columns[i].GetValue(obj));
             break;
         case Connection.CLIType.cli_int2:
             buf.putShort((short)columns[i].GetValue(obj));
             break;
         case Connection.CLIType.cli_int4:
             buf.putInt((int)columns[i].GetValue(obj));
             break;
         case Connection.CLIType.cli_int8:
             buf.putLong((long)columns[i].GetValue(obj));
             break;
         case Connection.CLIType.cli_real4:
             buf.putFloat((float)columns[i].GetValue(obj));
             break;
         case Connection.CLIType.cli_real8:
             buf.putDouble((double)columns[i].GetValue(obj));
             break;
         case Connection.CLIType.cli_bool:
             buf.putByte((bool)columns[i].GetValue(obj) ? 1 : 0);
             break;
         case Connection.CLIType.cli_oid:
             Reference r = (Reference)columns[i].GetValue(obj);
             buf.putInt(r != null ? r.oid : 0);
             break;
         case Connection.CLIType.cli_rectangle:
             Rectangle rect = (Rectangle)columns[i].GetValue(obj);
             if (rect == null)
             {
                 rect = new Rectangle();
             }
             buf.putRectangle(rect);
             break;
         case Connection.CLIType.cli_asciiz:
             buf.putString((string)columns[i].GetValue(obj));
             break;
         case Connection.CLIType.cli_datetime:
             buf.putInt((int)(((DateTime)columns[i].GetValue(obj)).Ticks / 1000000));
             break;
         case Connection.CLIType.cli_array_of_int1:
             buf.putByteArray((byte[])columns[i].GetValue(obj));
             break;
         case Connection.CLIType.cli_array_of_int2:
         {
             short[] arr = (short[])columns[i].GetValue(obj);
             len = arr == null ? 0 : arr.Length;
             buf.putInt(len);
             for (j = 0; j < len; j++)
             {
                 buf.putShort(arr[j]);
             }
             break;
         }
         case Connection.CLIType.cli_array_of_int4:
         {
             int[] arr = (int[])columns[i].GetValue(obj);
             len = arr == null ? 0 : arr.Length;
             buf.putInt(len);
             for (j = 0; j < len; j++)
             {
                 buf.putInt(arr[j]);
             }
             break;
         }
         case Connection.CLIType.cli_array_of_int8:
         {
             long[] arr = (long[])columns[i].GetValue(obj);
             len = arr == null ? 0 : arr.Length;
             buf.putInt(len);
             for (j = 0; j < len; j++)
             {
                 buf.putLong(arr[j]);
             }
             break;
         }
         case Connection.CLIType.cli_array_of_real4:
         {
             float[] arr = (float[])columns[i].GetValue(obj);
             len = arr == null ? 0 : arr.Length;
             buf.putInt(len);
             for (j = 0; j < len; j++)
             {
                 buf.putFloat(arr[j]);
             }
             break;
         }
         case Connection.CLIType.cli_array_of_real8:
         {
             double[] arr = (double[])columns[i].GetValue(obj);
             len = arr == null ? 0 : arr.Length;
             buf.putInt(len);
             for (j = 0; j < len; j++)
             {
                 buf.putDouble(arr[j]);
             }
             break;
         }
         case Connection.CLIType.cli_array_of_bool:
         {
             bool[] arr = (bool[])columns[i].GetValue(obj);
             len = arr == null ? 0 : arr.Length;
             buf.putInt(len);
             for (j = 0; j < len; j++)
             {
                 buf.putByte(arr[j] ? 1 : 0);
             }
             break;
         }
         case Connection.CLIType.cli_array_of_oid:
         {
             Reference[] arr = (Reference[])columns[i].GetValue(obj);
             len = arr == null ? 0 : arr.Length;
             buf.putInt(len);
             for (j = 0; j < len; j++)
             {
                 buf.putInt(arr[j] != null ? arr[j].oid : 0);
             }
             break;
         }
         case Connection.CLIType.cli_array_of_string:
         {
             string[] arr = (string[])columns[i].GetValue(obj);
             len = arr == null ? 0 : arr.Length;
             buf.putInt(len);
             for (j = 0; j < len; j++)
             {
                 buf.putAsciiz(arr[j]);
             }
             break;
         }
         case Connection.CLIType.cli_autoincrement:
             break;
         default:
             throw new CliError("Unsupported type " + types[i]);
     }
     }
 }