public static void getCellIDComponents(CellID64 cell, out int XMinComp, out int YMinComp, out int ZMinComp, out int XMaxComp, out int YMaxComp, out int ZMaxComp) { XMinComp = 0; YMinComp = 0; ZMinComp = 0; XMaxComp = 0; YMaxComp = 0; ZMaxComp = 0; int depth = CellID64.getLevel(cell); int maxDepth = 19; for (int i = 0; i < maxDepth; i++) { int tmpOffset = (int)((cell.iCellID & (UInt64)0x1 << (61 - i * 3)) >> (61 - i * 3 - (maxDepth - 1 - i))); XMinComp |= tmpOffset; tmpOffset = (int)((cell.iCellID & (UInt64)0x1 << (62 - i * 3)) >> (62 - i * 3 - (maxDepth - 1 - i))); YMinComp |= tmpOffset; tmpOffset = (int)((cell.iCellID & (UInt64)0x1 << (63 - i * 3)) >> (63 - i * 3 - (maxDepth - 1 - i))); ZMinComp |= tmpOffset; } // Get the max index by adding 1 (at depth) to get the next neighbor cell XMaxComp = XMinComp + (0x1 << (19 - depth)); YMaxComp = YMinComp + (0x1 << (19 - depth)); ZMaxComp = ZMinComp + (0x1 << (19 - depth)); }
public static string childrenCellCondition(CellID64 cellID) { string cellIDStr = cellID.ToString(); int usedCharIdx = (int)Math.Ceiling((double)(CellID64.getLevel(cellID) / 2)); string tmpStr = "(CELLID LIKE '" + cellIDStr.Substring(0, usedCharIdx) + "%' AND CELLID > '" + cellIDStr + "')"; return(tmpStr); }
public static List <string> parentCellList(CellID64 cellID) { List <string> cidList = new List <string>(); CellID64 pCell = cellID; for (int i = CellID64.getLevel(pCell); i > 0; i--) { pCell = CellID64.parentCell(pCell); cidList.Add(pCell.ToString()); } return(cidList); }
public static CellID64 parentCell(CellID64 cell) { UInt64 a = 0; for (int i = 0; i < CellID64.getLevel(cell) - 1; i++) { a |= cell.iCellID & (UInt64)7 << (61 - i * 3); } a |= (UInt64)(CellID64.getLevel(cell) - 1) << 1; CellID64 pCell = new CellID64(a); return(pCell); }
public static List <Point3D> getCellIdxCorner(CellID64 cell) { List <Point3D> cornerLoc = new List <Point3D>(); Point3D pos = new Point3D(); int depth = CellID64.getLevel(cell); Vector3D tileSize = cellSize(depth); pos = getCellIdxLoc(cell); cornerLoc.Add(pos); Point3D pos2 = new Point3D(pos.X + tileSize.X, pos.Y + tileSize.Y, pos.Z + tileSize.Z); cornerLoc.Add(pos2); return(cornerLoc); }
public static string parentsCellCondition(CellID64 cellID) { string tmpStr = ""; CellID64 pCell = cellID; for (int i = CellID64.getLevel(cellID); i > 0; i--) { if (i < CellID64.getLevel(cellID)) { tmpStr += " OR "; } pCell = CellID64.parentCell(pCell); tmpStr += "(CELLID = '" + pCell.ToString() + "' OR CELLID = '"; pCell.setBorderCell(); tmpStr += pCell.ToString() + "')"; } return(tmpStr); }
public static Point3D getCellIdxLoc(CellID64 cell) { Point3D pos = new Point3D(); int XOffset = 0; int YOffset = 0; int ZOffset = 0; int depth = CellID64.getLevel(cell); for (int i = 0; i < depth; i++) { int tmpOffset = (int)((cell.iCellID & (UInt64)0x1 << (61 - i * 3)) >> (61 - i * 3 - (depth - 1 - i))); XOffset |= tmpOffset; tmpOffset = (int)((cell.iCellID & (UInt64)0x1 << (62 - i * 3)) >> (62 - i * 3 - (depth - 1 - i))); YOffset |= tmpOffset; tmpOffset = (int)((cell.iCellID & (UInt64)0x1 << (63 - i * 3)) >> (63 - i * 3 - (depth - 1 - i))); ZOffset |= tmpOffset; } Vector3D tileSize = cellSize(depth); pos.X = XOffset * tileSize.X + Octree.WorldBB.LLB.X; pos.Y = YOffset * tileSize.Y + Octree.WorldBB.LLB.Y; pos.Z = ZOffset * tileSize.Z + Octree.WorldBB.LLB.Z; return(pos); }
/// <summary> /// Collect ALL the cellids from userDict for populating transient geometry(ies) /// </summary> /// <param name="elementIDList"></param> /// <param name="cellIDStrList"></param> /// <param name="borderFlagList"></param> public void collectSpatialIndexUserDict(out List <string> elementIDList, out List <string> cellIDStrList, out List <int> XMinB, out List <int> YMinB, out List <int> ZMinB, out List <int> XMaxB, out List <int> YMaxB, out List <int> ZMaxB, out List <int> depthList, out List <int> cellType) { int initArraySize = 50000; elementIDList = new List <string>(initArraySize); cellIDStrList = new List <string>(initArraySize); cellType = new List <int>(initArraySize); XMinB = new List <int>(initArraySize); YMinB = new List <int>(initArraySize); ZMinB = new List <int>(initArraySize); XMaxB = new List <int>(initArraySize); YMaxB = new List <int>(initArraySize); ZMaxB = new List <int>(initArraySize); depthList = new List <int>(initArraySize); int XMin; int YMin; int ZMin; int XMax; int YMax; int ZMax; foreach (KeyValuePair <UInt64, CellData> dictEntry in userDict) { CellID64 cellID = new CellID64(dictEntry.Key); if (dictEntry.Value.data != null) { foreach (int tupEID in dictEntry.Value.data) { ElementID eID = new ElementID(getElementIDByIndex(tupEID)); // For UserGeom, the ID i s generated from string of a simple number padded left with '0'. Now we need to remove them int end0Pos = 0; for (int i = 0; i < eID.ElementIDString.Length; ++i) { if (eID.ElementIDString[i] != '0') { end0Pos = i; break; } } string userGeomID = eID.ElementIDString.Remove(0, end0Pos); elementIDList.Add(userGeomID); cellIDStrList.Add(cellID.ToString()); // cellType.Add(eID.Value); cellType.Add(dictEntry.Value.nodeType); CellID64.getCellIDComponents(cellID, out XMin, out YMin, out ZMin, out XMax, out YMax, out ZMax); XMinB.Add(XMin); YMinB.Add(YMin); ZMinB.Add(ZMin); XMaxB.Add(XMax); YMaxB.Add(YMax); ZMaxB.Add(ZMax); depthList.Add(CellID64.getLevel(cellID)); } } } }