public static IKdTreeNode ReadNode(ModelLoadContext ctx) { var typeNode = ctx.Reader.ReadByte(); IKdTreeNode res; switch (typeNode) { case 0: res = null; break; case 1: res = new KdTreeNode(ctx); break; case 2: res = new KdTreeLeaf(ctx); break; default: throw Contracts.Except("Bad value for type: {0}", typeNode); } byte b = ctx.Reader.ReadByte(); if (b != 169) { throw Contracts.Except("Detected inconsistency in deserializing."); } return(res); }
public IKdTreeNode Add(IPointIdFloat point) { left = new KdTreeLeaf(depth + 1); right = new KdTreeLeaf(depth + 1); return(new KdTreeNode(point, left, right, depth)); }