예제 #1
0
 void processFiles(string path)
 {
     try
     {
         if (path.EndsWith(".txt"))
         {
             FileReader = new VoxTree_SetupFiles();
             startedJob = true;
             FileReader.readFile(path);
         }
     }
     catch (Exception e)
     {
         Debug.Log("You don't get the point do you...");
         Debug.LogError(e.Message);
     }
 }
예제 #2
0
    // Use this for initialization
    void Start()
    {
        //pointCloud = new VoxTreeData();
        setupFileReader = new VoxTree_SetupFiles();
        //Debug.Log("Current path: " + Directory.GetCurrentDirectory());
        importFilePath = Path.Combine(Directory.GetCurrentDirectory(), AssetDatabase.GetAssetPath(ClassifiedClouds[0]));
        importFilePath = importFilePath.Replace("/", "\\");
        exportFilePath = Path.Combine(Directory.GetCurrentDirectory(), folderExport, Path.GetFileNameWithoutExtension(importFilePath));

        if (!Directory.Exists(exportFilePath))
        {
            Directory.CreateDirectory(exportFilePath);
        }
        text.text = "Importing CSV from:\t" + importFilePath;
        Debug.Log("Importing CSV from:\t " + importFilePath);
        text.text = "\nExporting Files to:\t" + exportFilePath;
        Debug.Log("Exporting Files to:\t " + importFilePath);

        // TODO:
        // Have checksum file.
        // nFiles; first file name/size; last file name/size; random file name/size
        // Also cloud info.
        // nVoxels; Header info; date of construction; date of access

        if (Directory.GetFiles(exportFilePath).Length > 1)
        {
            Debug.Log(string.Format("{0} Files found in directory.", Directory.GetFiles(exportFilePath).Length));
            hasVoxTreeFiles = true;
        }
        else
        {
            hasVoxTreeFiles = false;
        }

        if (forceVoxTreeFilesSetup)
        {
            hasVoxTreeFiles = false;
        }

        if (!hasVoxTreeFiles)
        {
            setupFileReader.readFile(importFilePath);
        }
    }
예제 #3
0
    void getAverages(VoxTree_SetupFiles Cloud, float averageSizes, float bucketSize)
    {
        //float[] _AverageSizes = new float[averageSizes.Length];
        //averageSizes.CopyTo(_AverageSizes, 0);


        if (Cloud.hasFinished && Cloud.getData != null && writtenAverages < 0)
        {
            if (headings == null)
            {
                headings = Cloud.headerNames.Clone() as string[];
            }
            writtenAverages = 0;
            Debug.Log("getting averages...");
            foreach (var subCloud in Cloud.getData)
            //Parallel.ForEach(Cloud.getData, (subCloud) =>
            {
                Debug.Log("Averaging next column...");
                // create temp dictionary for each bucket.
                Dictionary <Vector3, double[]> tempAveData = new Dictionary <Vector3, double[]>();
                Vector3 tempKey;

                for (int i = 0; i < subCloud.Value.Count; i++)
                {
                    tempKey = GetBucketKey(subCloud.Value[i], averageSizes);
                    if (tempAveData.ContainsKey(tempKey))
                    {
                        getAveragedPoint(tempAveData[tempKey], subCloud.Value[i], tempKey);
                    }
                    else
                    {
                        tempAveData.Add(tempKey, getAveragedPoint(null, subCloud.Value[i], tempKey));
                    }
                }

                // add each threaded buckets to the shared memory.

                AddOrUpdate(ref sharedData, tempAveData, averageSizes, bucketSize);
                //bucketVoxels.Add()

                /*
                 * foreach (var item in tempAveData)
                 * {
                 *  AddOrUpdate(ref sharedData, tempAveData, averageSizes, bucketSize);
                 * }
                 */
            }
            // Used to write multiple buckets at once.

            /*
             * Parallel.ForEach(Cloud.getData, (subCloud) =>
             * {
             *  // create temp dictionary for each bucket.
             *  Dictionary<float, Dictionary<Vector3, double[]>> tempBucketedData = new Dictionary<float, Dictionary<Vector3, double[]>>();
             *  Vector3 tempKey;
             *  for (int j = 0; j < _AverageSizes.Length; j++)
             *  {
             *      if (!tempBucketedData.ContainsKey(_AverageSizes[j]))
             *      {
             *          tempBucketedData.Add(_AverageSizes[j], new Dictionary<Vector3, double[]>());
             *      }
             *  }
             *
             *  for (int i = 0; i < subCloud.Value.Count; i++)
             *  {
             *      for (int j = 0; j < _AverageSizes.Length; j++)
             *      {
             *          tempKey = GetBucketKey(subCloud.Value[i], _AverageSizes[j]);
             *          if (tempBucketedData[_AverageSizes[j]].ContainsKey(tempKey))
             *          {
             *              getAveragedPoint(tempBucketedData[_AverageSizes[j]][tempKey], subCloud.Value[i], tempKey);
             *          }
             *          else
             *          {
             *              tempBucketedData[_AverageSizes[j]].Add(tempKey, getAveragedPoint(null, subCloud.Value[i], tempKey));
             *              //tempBucketedData[_AverageSizes[j]][tempKey].Add(subCloud.Value[i]);
             *          }
             *      }
             *  }
             *
             *  // add each threaded buckets to the shared memory.
             *  foreach (var item in tempBucketedData)
             *  {
             *      AddOrUpdate(ref sharedBucketedData, item.Key, item.Value);
             *  }
             * });
             */
            writtenAverages = 1;
            //averageBucketz(ref sharedBucketedData);

            Debug.Log("Finished averaging...");

            foreach (var item in sharedData)
            {
                nPoints += item.Value.Count;
            }
            nBuckets = sharedData.Count;
        }
    }