예제 #1
0
                public void WriteClusters(SySal.Imaging.Cluster[] cls, System.IO.StreamWriter w)
                {
                    if (w.BaseStream.Position == 0)
                    {
                        w.WriteLine("SEQUENCE\tLAYER\tTOTAL\tSTAGEX\tSTAGEY\tSTAGEZ\tID\tCLSX\tCLSY\tAREA\tIMXX\tIMYY\tIMXY");
                    }
                    int i;

                    for (i = 0; i < cls.Length; i++)
                    {
                        SySal.Imaging.Cluster c = cls[i];
                        w.WriteLine(Owner.Id + "\t" + Id + "\t" + cls.Length + "\t" +
                                    Position.X.ToString("F2", System.Globalization.CultureInfo.InvariantCulture) + "\t" +
                                    Position.Y.ToString("F2", System.Globalization.CultureInfo.InvariantCulture) + "\t" +
                                    Position.Z.ToString("F2", System.Globalization.CultureInfo.InvariantCulture) + "\t" +
                                    i + "\t" +
                                    c.X.ToString("F2", System.Globalization.CultureInfo.InvariantCulture) + "\t" +
                                    c.Y.ToString("F2", System.Globalization.CultureInfo.InvariantCulture) + "\t" +
                                    c.Area + "\t" +
                                    c.Inertia.IXX.ToString() + "\t" +
                                    c.Inertia.IYY.ToString() + "\t" +
                                    c.Inertia.IXY.ToString());
                    }
                    this.Clusters = (uint)cls.Length;
                }
예제 #2
0
 public SySal.Imaging.Cluster[] ReadClusters()
 {
     System.IO.StreamReader r = null;
     try
     {
         r = new System.IO.StreamReader(ClusterMapFileName);
         string line;
         System.Collections.ArrayList a = new System.Collections.ArrayList();
         while ((line = r.ReadLine()) != null)
         {
             System.Text.RegularExpressions.Match m = rx_Clusters.Match(line);
             if (m.Success && m.Index == 0 && m.Length == line.Length)
             {
                 SySal.Imaging.Cluster c = new SySal.Imaging.Cluster();
                 c.Area        = uint.Parse(m.Groups["AREA"].Value);
                 c.X           = double.Parse(m.Groups["CLSX"].Value, System.Globalization.CultureInfo.InvariantCulture);
                 c.Y           = double.Parse(m.Groups["CLSY"].Value, System.Globalization.CultureInfo.InvariantCulture);
                 c.Inertia.IXX = long.Parse(m.Groups["IMXX"].Value);
                 c.Inertia.IYY = long.Parse(m.Groups["IMYY"].Value);
                 c.Inertia.IXY = long.Parse(m.Groups["IMXY"].Value);
                 a.Add(c);
             }
         }
         Clusters = (uint)a.Count;
         return((SySal.Imaging.Cluster[])a.ToArray(typeof(SySal.Imaging.Cluster)));
     }
     finally
     {
         if (r != null)
         {
             r.Close();
         }
     }
 }
예제 #3
0
                public void WriteClusters(SySal.Imaging.Cluster[] cls, System.IO.MemoryStream ms)
                {
                    System.IO.BinaryWriter bw = new System.IO.BinaryWriter(ms);
                    bw.Write(Id);
                    bw.Write(cls.Length);
                    bw.Write(Position.X);
                    bw.Write(Position.Y);
                    bw.Write(Position.Z);
                    int i;

                    for (i = 0; i < cls.Length; i++)
                    {
                        SySal.Imaging.Cluster c = cls[i];
                        bw.Write(c.Area);
                        bw.Write(c.X);
                        bw.Write(c.Y);
                        bw.Write(c.Inertia.IXX);
                        bw.Write(c.Inertia.IXY);
                        bw.Write(c.Inertia.IYY);
                    }
                    this.Clusters = (uint)cls.Length;
                }
예제 #4
0
 public void WriteClusters(SySal.Imaging.Cluster [] cls)
 {
     System.IO.StreamWriter w = null;
     try
     {
         System.IO.MemoryStream ms = new System.IO.MemoryStream();
         w = new System.IO.StreamWriter(ms);
         w.WriteLine("SEQUENCE\tLAYER\tTOTAL\tSTAGEX\tSTAGEY\tSTAGEZ\tID\tCLSX\tCLSY\tAREA\tIMXX\tIMYY\tIMXY");
         int i;
         for (i = 0; i < cls.Length; i++)
         {
             SySal.Imaging.Cluster c = cls[i];
             w.WriteLine(Owner.Id + "\t" + Id + "\t" + cls.Length + "\t" +
                         Position.X.ToString("F2", System.Globalization.CultureInfo.InvariantCulture) + "\t" +
                         Position.Y.ToString("F2", System.Globalization.CultureInfo.InvariantCulture) + "\t" +
                         Position.Z.ToString("F2", System.Globalization.CultureInfo.InvariantCulture) + "\t" +
                         i + "\t" +
                         c.X.ToString("F2", System.Globalization.CultureInfo.InvariantCulture) + "\t" +
                         c.Y.ToString("F2", System.Globalization.CultureInfo.InvariantCulture) + "\t" +
                         c.Area + "\t" +
                         c.Inertia.IXX.ToString() + "\t" +
                         c.Inertia.IYY.ToString() + "\t" +
                         c.Inertia.IXY.ToString());
         }
         w.Flush();
         w.Close();
         System.IO.File.WriteAllBytes(ClusterMapFileName, ms.ToArray());
         this.Clusters = (uint)cls.Length;
     }
     finally
     {
         if (w != null)
         {
             w.Close();
         }
     }
 }