private void Cleanup() { ClearMeshes(); corrupted = false; tree?.Dispose(); tree = null; }
/// <summary> /// Creates new instance of node loader under specified node tree. /// </summary> /// <param name="owner">Node tree tho which this instance belongs to.</param> /// <param name="loadedPointsLimit">Maximum amount of points that can be present in memory at a time.</param> public NodeLoader(NodeTree owner, int loadedPointsLimit) { this.owner = owner; pointLimit = loadedPointsLimit; StartLoaderThread(); }
/// <summary> /// Attempts to load index file with tree meta data from disk and create appropriate instance of node tree. /// </summary> /// <param name="path">Directory under which tree data is stored.</param> /// <param name="pointLimit">Maximum amount of points that tree can store in memory at once.</param> /// <param name="instance">Newly created instance of the node tree.</param> /// <returns>True if load was successful, false otherwise.</returns> public static bool TryLoadFromDisk(string path, int pointLimit, out NodeTree instance) { var fullPath = Utility.GetFullPath(path); var indexPath = Path.Combine(fullPath, "index" + TreeUtility.IndexFileExtension); if (!File.Exists(indexPath)) { Debug.LogError("Index file not found."); instance = null; return(false); } NodeTree result = null; try { var indexData = IndexData.ReadFromFile(indexPath); if (indexData.TreeType == TreeType.Octree) { result = new Octree(fullPath, pointLimit); } else { result = new Quadtree(fullPath, pointLimit); } foreach (var nodeMetaData in indexData.Data) { var nodeRecord = result.CreateNodeRecord(nodeMetaData); result.NodeRecords.Add(nodeRecord.Identifier, nodeRecord); } result.RebuildHierarchy(); instance = result; return(true); } catch (Exception e) { Debug.LogError($"{e.Message}\n{e.StackTrace}"); result?.Dispose(); instance = null; return(false); } }
public void Refresh(NodeTree tree, ComputeBuffer buffer, int validPointCount) { pointCount = validPointCount; renderedTree = tree; Buffer = buffer; }
private void OnDestroy() { tree?.Dispose(); tree = null; }
/// <summary> /// Attempts to load index file with tree meta data from disk and create appropriate instance of node tree. /// </summary> /// <param name="path">Directory under which tree data is stored.</param> /// <param name="pointLimit">Maximum amount of points that tree can store in memory at once.</param> /// <param name="dataHash">Hash of the point cloud data (only applicable to ZIP files).</param> /// <param name="instance">Newly created instance of the node tree.</param> /// <returns>True if load was successful, false otherwise.</returns> public static bool TryLoadFromDisk(string path, int pointLimit, string dataHash, out NodeTree instance) { var fullPath = Utility.GetFullPath(path); string indexPath; long offset, size; ZipTreeData zipData = null; if (!string.IsNullOrEmpty(dataHash)) { indexPath = fullPath; zipData = new ZipTreeData(indexPath, dataHash); const string indexName = "index" + TreeUtility.IndexFileExtension; size = zipData.GetEntrySize(indexName); offset = zipData.GetEntryOffset(indexName); } else { indexPath = Path.Combine(fullPath, "index" + TreeUtility.IndexFileExtension); if (!File.Exists(indexPath)) { instance = null; return(false); } size = new FileInfo(indexPath).Length; offset = 0; } NodeTree result = null; try { var indexData = IndexData.ReadFromFile(indexPath, offset, size); if (indexData.TreeType == TreeType.Octree) { result = new Octree(fullPath, pointLimit, zipData); } else { result = new Quadtree(fullPath, pointLimit, zipData); } foreach (var nodeMetaData in indexData.Data) { var nodeRecord = result.CreateNodeRecord(nodeMetaData); result.NodeRecords.Add(nodeRecord.Identifier, nodeRecord); } result.RebuildHierarchy(); instance = result; return(true); } catch (Exception e) { Debug.LogError($"{e.Message}\n{e.StackTrace}"); result?.Dispose(); instance = null; return(false); } }
private void Cleanup() { corrupted = false; tree?.Dispose(); tree = null; }