Exemple #1
0
        int[][] CreateColorArray(int[][] colors)
        {
            DateTime startTime = DateTime.Now;

            string[] sourceLines = File.ReadAllLines(sourcePath);

            //iterate through lines, sending out a min/max check
            ProgressCounter colorProgress = new ProgressCounter(fileLength);

            Console.WriteLine("Reading RGB array:");

            for (int i = 0; i < fileLength; i++)
            {
                string[] pointParameters = sourceLines[i].Split(' ');

                colors[i] = new int[3];

                try { colors[i][0] = Convert.ToInt32(pointParameters[3]); } catch { colors[i][0] = 0; errors++; }
                try { colors[i][1] = Convert.ToInt32(pointParameters[4]); } catch { colors[i][1] = 0; errors++; }
                try { colors[i][2] = Convert.ToInt32(pointParameters[5]); } catch { colors[i][2] = 0; errors++; }

                colorProgress.Increment();
            }
            Console.WriteLine("\n");
            return(colors);
        }
Exemple #2
0
        private void WriteNewFiles(List <string>[][] sortedPoints, string[][] destinationPaths, int divisions)
        {
            ProgressCounter writeProgress = new ProgressCounter(divisions * divisions);

            for (int i = 0; i < divisions; i++)
            {
                for (int j = 0; j < divisions; j++)
                {
                    string[] lineArray = sortedPoints[i][j].ToArray();
                    File.WriteAllLines(destinationPaths[i][j], lineArray);

                    writeProgress.Increment();
                }
            }
            Console.WriteLine("");
            return;
        }
Exemple #3
0
        private List <string>[][] SortPoints(List <string>[][] sortedPoints, float[][] coordinates, int[][] colors, int divisions)
        {
            ProgressCounter sortProgress = new ProgressCounter(fileLength);
            ErrorLogger     sortErrors   = new ErrorLogger(destinationLocation, "sorting");

            //initialize the lists within dortedPoints
            for (int i = 0; i < divisions; i++)
            {
                sortedPoints[i] = new List <string> [divisions];
                for (int j = 0; j < divisions; j++)
                {
                    sortedPoints[i][j] = new List <string>();
                }
            }

            for (int i = 0; i < fileLength; i++)
            {
                int sortX;
                int sortY;
                sortX = Convert.ToInt32(Math.Floor((coordinates[i][0] - xMin) / (deltaX / divisions)));
                sortY = Convert.ToInt32(Math.Floor((coordinates[i][1] - yMin) / (deltaY / divisions)));

                string newLine = coordinates[i][0].ToString() + " ";
                newLine += coordinates[i][1].ToString() + " ";
                newLine += coordinates[i][2].ToString() + " ";
                newLine += colors[i][0].ToString() + " ";
                newLine += colors[i][1].ToString() + " ";
                newLine += colors[i][2].ToString() + " ";

                try { sortedPoints[sortX][sortY].Add(newLine); }
                catch
                {
                    errors++;
                    sortErrors.AddError(ErrorBuilder(i));
                }


                sortProgress.Increment();
            }

            sortErrors.writeErrorLog();
            return(sortedPoints);
        }
Exemple #4
0
        //converts the bunch of text into a jagged array of coordinates and a matching jagged array of RGB values.
        float[][] CreateCoordinateArray(float[][] coordinates)
        {
            ProgressCounter coordinateProgress    = new ProgressCounter(fileLength);
            ErrorLogger     CoordinateArrayErrors = new ErrorLogger(destinationLocation, "coordinate");

            string[] sourceLines = File.ReadAllLines(sourcePath);

            //iterate through lines, sending out a min/max check
            Console.WriteLine("Building data array:");
            for (int i = 0; i < fileLength; i++)
            {
                string[] pointParameters = sourceLines[i].Split(' ');

                coordinates[i] = new float[3];
                try { coordinates[i][0] = Convert.ToSingle(pointParameters[0]); } catch { coordinates[i][0] = 0; errors++; CoordinateArrayErrors.AddError(ErrorBuilder(i)); }
                try { coordinates[i][1] = Convert.ToSingle(pointParameters[1]); } catch { coordinates[i][1] = 0; errors++; CoordinateArrayErrors.AddError(ErrorBuilder(i)); }
                try { coordinates[i][2] = Convert.ToSingle(pointParameters[2]); } catch { coordinates[i][2] = 0; errors++; CoordinateArrayErrors.AddError(ErrorBuilder(i)); }
                coordinateProgress.Increment();
            }
            Console.WriteLine("\n");
            CoordinateArrayErrors.writeErrorLog();
            return(coordinates);
        }
Exemple #5
0
        //runs through the pointcloud once to analyze size/location of the pointcloud to determine the cut lines
        void getLimits(float[][] coordinates)
        {
            DateTime startTime = DateTime.Now;

            string[] sourceLines = File.ReadAllLines(sourcePath);

            //iterate through lines, sending out a min/max check
            ProgressCounter limitProgress = new ProgressCounter(sourceLines.Length);

            Console.WriteLine("Analyzing limits:");
            for (int i = 0; i < sourceLines.Length; i++)
            {
                string[] pointParameters = sourceLines[i].Split(' ');

                xMin = CheckMin(xMin, coordinates[i][0]);
                xMax = CheckMax(xMax, coordinates[i][0]);
                yMin = CheckMin(yMin, coordinates[i][1]);
                yMax = CheckMax(yMax, coordinates[i][1]);
                zMin = CheckMin(zMin, coordinates[i][2]);
                zMax = CheckMax(zMax, coordinates[i][2]);

                limitProgress.Increment();
            }

            deltaX = xMax - xMin;
            deltaY = yMax - yMin;
            deltaZ = zMax - zMin;

            Console.WriteLine("");
            Console.WriteLine(@"Point Limits: xMin_{0} xMax_{1} yMin_{2} yMax_{3} zMin_{4} xMax_{5}",
                              xMin, xMax, yMin, yMax, zMin, zMax);
            Console.WriteLine(@"Coordinate ranges: X_{0}, Y_{1}, Z_{2}", deltaX, deltaY, deltaZ);
            DateTime endTime = DateTime.Now;

            Console.WriteLine(@"Time to get limits: {0}", endTime - startTime);
        }