Exemple #1
0
        public void PointRead(Node node, StreamWriter writer, point3D rp)
        {
            var convertRGB = new HSVtoRGB();

            deep++;

            if (node.count != 0)
            {
                #region ストリームライター
                int[] RGB = { 0, 0, 0 };
                RGB = convertRGB.Convert_RGB((250 - 250 * node.count / 100000), 1, 1);
                writer.WriteLine(rp.X + "," + rp.Y + "," + rp.Z + "," + RGB[0] + "," + RGB[1] + "," + RGB[2] + "," + node.count);
                node = null;
                deep--;
                return;

                #endregion
                #region ファイルライター?

                /*
                 * int[] RGB = { 0, 0, 0 };
                 * RGB = convertRGB.Convert_RGB((250 - 250 * node.count / 100000), 1, 1);
                 * File.AppendAllText(@"C:\test\octree2.txt", node.point.X + "," + node.point.Y + "," + node.point.Z + ","  + RGB[0] + "," + RGB[1] + "," + RGB[2] +","+node.count+","+ Environment.NewLine);
                 */
                #endregion
            }


            if (node.children != null && node.children[0] != null)
            {
                PointRead(node.children[0], writer, new point3D.pget(rp.X - Form1.check_area / Math.Pow(2, deep), rp.Y - Form1.check_area / Math.Pow(2, deep), rp.Z - Form1.check_area / Math.Pow(2, deep)));
            }
            if (node.children != null && node.children[1] != null)
            {
                PointRead(node.children[1], writer, new point3D.pget(rp.X - Form1.check_area / Math.Pow(2, deep), rp.Y - Form1.check_area / Math.Pow(2, deep), rp.Z + Form1.check_area / Math.Pow(2, deep)));
            }
            if (node.children != null && node.children[2] != null)
            {
                PointRead(node.children[2], writer, new point3D.pget(rp.X - Form1.check_area / Math.Pow(2, deep), rp.Y + Form1.check_area / Math.Pow(2, deep), rp.Z - Form1.check_area / Math.Pow(2, deep)));
            }
            if (node.children != null && node.children[3] != null)
            {
                PointRead(node.children[3], writer, new point3D.pget(rp.X - Form1.check_area / Math.Pow(2, deep), rp.Y + Form1.check_area / Math.Pow(2, deep), rp.Z + Form1.check_area / Math.Pow(2, deep)));
            }
            if (node.children != null && node.children[4] != null)
            {
                PointRead(node.children[4], writer, new point3D.pget(rp.X + Form1.check_area / Math.Pow(2, deep), rp.Y - Form1.check_area / Math.Pow(2, deep), rp.Z - Form1.check_area / Math.Pow(2, deep)));
            }
            if (node.children != null && node.children[5] != null)
            {
                PointRead(node.children[5], writer, new point3D.pget(rp.X + Form1.check_area / Math.Pow(2, deep), rp.Y - Form1.check_area / Math.Pow(2, deep), rp.Z + Form1.check_area / Math.Pow(2, deep)));
            }
            if (node.children != null && node.children[6] != null)
            {
                PointRead(node.children[6], writer, new point3D.pget(rp.X + Form1.check_area / Math.Pow(2, deep), rp.Y + Form1.check_area / Math.Pow(2, deep), rp.Z - Form1.check_area / Math.Pow(2, deep)));
            }
            if (node.children != null && node.children[7] != null)
            {
                PointRead(node.children[7], writer, new point3D.pget(rp.X + Form1.check_area / Math.Pow(2, deep), rp.Y + Form1.check_area / Math.Pow(2, deep), rp.Z + Form1.check_area / Math.Pow(2, deep)));
            }
            deep--;
            return;
        }
Exemple #2
0
        private void exe_Click(object sender, EventArgs e)
        {
            var counter = new CycleMeasurementMemory(this);

            counter.Start(TimeSpan.FromMilliseconds(1000)); // 1秒間隔で計測実行
            octree.boxelsize = double.Parse(splitsize.Text) / 1000;
            //Console.WriteLine("Start!");
            localconsole.Text = "Start!\r\n";
            localconsole.Update();
            var sw = new System.Diagnostics.Stopwatch();

            sw.Restart();
            long usememory = Environment.WorkingSet;

            Node    root      = new Node();
            point3D readpoint = new point3D();
            var     Octree    = new octree();


            foreach (string st in list)
            {
                using (StreamReader sr = new StreamReader(st, Encoding.GetEncoding("Shift_JIS")))
                {
                    while ((line = sr.ReadLine()) != null)
                    {
                        string[] splitted = line.Split(',');
                        try
                        {
                            octree.cp.X = float.Parse(splitted[1]);
                            octree.cp.Y = float.Parse(splitted[0]);
                            octree.cp.Z = float.Parse(splitted[2]);
                            Octree.PointWrite(root, check_area);
                            if (maxmemory < Environment.WorkingSet)
                            {
                                maxmemory = Environment.WorkingSet;
                            }
                        }
                        catch (Exception error)
                        {
                            continue;
                        }
                    }
                }
            }
            //Console.WriteLine("読み込み終了");
            localconsole.Text += "読み込み終了\r\n";
            localconsole.Update();

            Encoding sjisEnc = Encoding.GetEncoding("Shift_JIS");

            using (StreamWriter writer = new StreamWriter(@"C:\test\" + WriteFile.Text, true, sjisEnc))
            {
                Octree.PointRead(root, writer, rootpoint);
            }
            sw.Stop();
            pointmax.Text     = Form1.count.mpoint.ToString();
            pointaverage.Text = Form1.count.average.ToString();
            exetime.Text      = sw.Elapsed.ToString();
            //Console.WriteLine("書き出し終了");
            localconsole.Text += "書き出し終了\r\n";
            localconsole.Update();
            counter.Stop();
            //Console.WriteLine("UseMemory:" + maxmemory);
            memory.Text = maxmemory.ToString();
            //Console.WriteLine("Finished! Time:" + sw.Elapsed);
            localconsole.Text += "Finished!\r\n";
            localconsole.Update();
        }
 public void AddPoint(point3D point)
 {
     this.points.Add(point);
 }
 public void AddPoints(point3D[] pointsArray)
 {
     foreach (var item in pointsArray)
     {
         this.points.Add(item);
     }
 }
 public static point3D GetDistance(point3D pointOne, point3D pointTwo)
 {
     point3D distance = new point3D(0, 0, 0);
     distance.X = Math.Abs(pointOne.X - pointTwo.X);
     distance.Y = Math.Abs(pointOne.Y - pointTwo.Y);
     distance.Z = Math.Abs(pointOne.Z - pointTwo.Z);
     return distance;
 }
 static void Main()
 {
     Path newPath = new Path();
     string path = "(1 2 3), (3 4 5), (8 9 10)";
     newPath.AddPoints(path);
     point3D newPoint = new point3D(13, 22, 4);
     newPath.AddPoint(newPoint);
     PointsStorage.SavePath(newPath);
     Path loadedPath = PointsStorage.LoadPath();
     foreach (var item in loadedPath.Points)
     {
         Console.WriteLine(item);
     }
 }
    public void AddPoints(string points)
    {
        string[] allPoints = points.Split(',');
        for (int index = 0; index < allPoints.Length; index++)
        {
            allPoints[index] = allPoints[index].Replace("(", "").Replace(")", "").Trim();
            string[] eachCoordinate = allPoints[index].Split();
            if (eachCoordinate[0] != "")
            {
                point3D newPoint = new point3D(int.Parse(eachCoordinate[0]), int.Parse(eachCoordinate[1]), int.Parse(eachCoordinate[2]));
                this.points.Add(newPoint);
            }

        }
    }
 public void AddPoint(point3D point)
 {
     this.points.Add(point);
 }