コード例 #1
0
 /// <summary>
 /// Sets aliases
 /// </summary>
 protected void SetAliases()
 {
     foreach (int key in aliases.Keys)
     {
         AliasName an = aliases[key];
         an.SetValue(state[key]);
     }
 }
コード例 #2
0
        private object[] Calculate(double[] position)
        {
            int n = facets.Count;

            for (int ic = 0; ic < n; ic++)
            {
                double[] p = facets[ic];
                for (int i = 0; i < position.Length; i++)
                {
                    AliasName an = al[i];
                    an.SetValue(position[i] - p[i]);
                }
                if (area != null)
                {
                    area.SetValue(facets.GetArea(ic));
                }
                foreach (int k in parameters.Keys)
                {
                    parameters[k].SetValue(facets[ic, k]);
                }
                if (normal != null)
                {
                    normal.SetValue(facets.GetNormal(ic));
                }
                foreach (IMeasurements m in measurements)
                {
                    m.UpdateMeasurements();
                }
                for (int i = 0; i < measures.Length; i++)
                {
                    object o = measures[i].Parameter();
                    result[i] = adds[i](result[i], o);
                }
                this.FullReset();

                /*    foreach (IMeasurements m in measurements)
                 *  {
                 *      isUpdated[m] = false;
                 *  }*/
            }
            return(result);
        }
コード例 #3
0
 /// <summary>
 /// Calculates field
 /// </summary>
 /// <param name="position">Position</param>
 /// <returns>Array of components of field</returns>
 public virtual object[] this[double[] position]
 {
     get
     {
         for (int i = 0; i < position.Length; i++)
         {
             AliasName an = al[i];
             an.SetValue(position[i]);
         }
         foreach (IMeasurements m in measurements)
         {
             m.UpdateMeasurements();
         }
         for (int i = 0; i < measures.Length; i++)
         {
             result[i] = measures[i].Parameter();
         }
         this.FullReset();
         return(result);
     }
 }
コード例 #4
0
        /// <summary>
        /// Process
        /// </summary>
        private void Process()
        {
            IDataConsumer cons = this;

            if (provider == null)
            {
                bmp = null;
                return;
            }
            if (provider.Bitmap == null)
            {
                return;
            }
            if (colorAliases == null)
            {
                return;
            }
            if (extColors == null)
            {
                return;
            }
            Bitmap b = provider.Bitmap;

            if (b == null)
            {
                return;
            }
            bmp = new Bitmap(b.Width, b.Height);
            int right  = colorAliases.GetLength(0) - left;
            int bottom = colorAliases.GetLength(1) - top;

            for (int i = 0; i < bmp.Width; i++)
            {
                int ii = i - left;
                if ((ii < 0) | (i + right >= bmp.Width))
                {
                    continue;
                }
                for (int j = 0; j < bmp.Height; j++)
                {
                    int jj = j - top;
                    if ((jj < 0) | (j + bottom >= bmp.Height))
                    {
                        continue;
                    }
                    double x = (double)i;
                    double y = (double)j;
                    if (coord[0] != null)
                    {
                        coord[0].SetValue(x);
                    }
                    if (coord[1] != null)
                    {
                        coord[1].SetValue(y);
                    }
                    for (int k = 0; k < extColors.GetLength(0); k++)
                    {
                        int xc = ii + k;
                        for (int l = 0; l < extColors.GetLength(1); l++)
                        {
                            int   yc = jj + l;
                            Color c  = b.GetPixel(xc, yc);
                            hc[0] = c.R;
                            hc[1] = c.G;
                            hc[2] = c.B;
                            for (int m = 0; m < hc.Length; m++)
                            {
                                AliasName ext = extColors[k, l, m];
                                if (ext != null)
                                {
                                    ext.SetValue(((double)hc[m]) / 255);
                                }
                            }
                        }
                    }
                    update();
                    for (int n = 0; n < measures.Length; n++)
                    {
                        IMeasurement mea = measures[n];
                        if (mea == null)
                        {
                            hco[n] = 0;
                        }
                        else
                        {
                            double cd = (double)mea.Parameter();
                            int    cn = (int)(cd * 255);
                            if (cn > 255)
                            {
                                cn = 255;
                            }
                            hco[n] = cn;
                        }
                    }
                    Color co = Color.FromArgb(255, hco[0], hco[1], hco[2]);
                    bmp.SetPixel(i, j, co);
                }
            }
        }