예제 #1
0
        private Point Destination(Indicatrix A)
        {
            Point2D result = A.Position;

            result += new Point2D(1.0, 1.0);
            result /= 2.0;
            result *= (height - 2 * buffer);
            result += new Point2D(width/2 + buffer, buffer);

            return new Point((int)result.X, (int)result.Y);
        }
예제 #2
0
 protected virtual void GrowNet(int idxneeded)
 {
     if (idxneeded >= Size)
     {
         int oldsize = m_Size;
         Indicatrix[,] tmp = new Indicatrix[idxneeded + 1, idxneeded + 1];
         for (int i = 0; i < oldsize; i++)
             for (int j = 0; j < oldsize; j++)
                 tmp[i, j] = m_Net[i, j];
         m_Net = tmp;
         m_Size = idxneeded + 1;
     }
 }
예제 #3
0
 protected virtual void InitializeWithDefault()
 {
     //default values:
     for (int i = 0; i < m_Size; i++)
     {
         for (int j = 0; j < m_Size; j++)
         {
             m_Net[i, j] = new Indicatrix(new Point2D(i, j), 0.0, 1.0 );
         }
     }
 }
예제 #4
0
        public virtual void DoubleResolution()
        {
            Indicatrix[,] old = m_Net;
            int oldsize = m_Size;
            m_Size = (m_Size - 1) * 2 + 1;
            m_Net = new Indicatrix[m_Size, m_Size];

            for (int i = 0; i < m_Size; i++)
            {
                for (int j = 0; j < m_Size; j++ )
                {
                    //copy from original grid
                    if (i % 2 == 0 && j % 2 == 0)
                    {
                        m_Net[i,j] = old[i/2,j/2];
                        if( m_Net[i,j] != null)
                        {
                            m_Net[i,j].Size /= 2.0;
                        }
                    }
                    else
                    {
                        //otherwise any points from the original grid in a 3x3 square around this vertex
                        int count = 0;
                        m_Net[i, j] = new Indicatrix(Point2D.Origin, 0, 0.0);
                        for( int ii=i-1;ii<=i+1;ii++)
                        {
                            for(int jj=j-1;jj<=j+1;jj++)
                            {
                                if( ii < 0 || jj < 0 || ii >= m_Size || jj >= m_Size )
                                    continue;
                                if( ii%2==1 || jj%2 == 1)
                                    continue;
                                if( old[ii/2,jj/2] == null )
                                    continue;
                                count++;
                                m_Net[i,j].Position += old[ii/2,jj/2].Position;
                                m_Net[i,j].Size += old[ii/2, jj/2].Size;
                                m_Net[i,j].Theta += old[ii/2, jj/2].Theta;
                            }
                        }
                        if( count > 0 )
                        {
                            m_Net[i,j].Position /= count;
                            m_Net[i,j].Size /= count;
                            DMS.FixAnglePositive(m_Net[i,j].Theta);
                            m_Net[i,j].Theta /= count;
                        }
                        else
                        {
                            m_Net[i,j].Size = 1.0;
                        }
                    }
                }
            }
        }
예제 #5
0
        public void AlignEdge(Indicatrix A, Indicatrix B, Aligner Al)
        {
            Point2D
                APos = null,
                BPos = null;

            for (int i = 0; i < m_Size; i++ )
            {
                for( int j=0; j<m_Size; j++ )
                {
                    if( m_Net[i,j]==A) APos = new Point2D(i,j);
                    if( m_Net[i,j]==B) BPos = new Point2D(i,j);
                }
            }

            for (int i = 0; i < m_Size; i++ )
            {
                for( int j=0; j<m_Size; j++ )
                {
                    if (m_Net[i,j] == null)
                        continue;
                    Point2D indexpos = new Point2D(i,j);

                    if (indexpos == A.Position ||
                        indexpos == B.Position ||
                        Math.Abs(Point2D.Angle(APos, indexpos, BPos) - Math.PI) < 1.0e-3)
                    {
                        m_Net[i,j].Alignment = Al;
                    }
                }
            }
        }
예제 #6
0
        public Net(String Filename)
            : this(1)
        {
            StreamReader sr = new StreamReader(Filename);
            while (!sr.EndOfStream)
            {
                String[] LinesIn = sr.ReadLine().Split(',');
                if (LinesIn.Count<String>() >= 6)
                {
                    int i = int.Parse(LinesIn[0]);
                    int j = int.Parse(LinesIn[1]);
                    double x = double.Parse(LinesIn[2]);
                    double y = double.Parse(LinesIn[3]);
                    double Theta = double.Parse(LinesIn[4]);
                    double Size = double.Parse(LinesIn[5]);

                    this[i, j] = new Indicatrix(new Point2D(x, y), Theta, Size );
                }
            }
            sr.Close();
            SetNeighbors();
        }
예제 #7
0
 public void SetNeighbors(Indicatrix North, Indicatrix South, Indicatrix East, Indicatrix West)
 {
     m_North = North;
     m_South = South;
     m_East = East;
     m_West = West;
 }
예제 #8
0
        public Indicatrix(Point2D pos, double theta, double size)
        {
            m_Position = pos;
            m_Theta = theta;
            m_Size = size;

            Save();

            m_North = m_South = m_East = m_West = null;

            m_Alignment = new Aligner();
        }