Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static GridVectorField3d CreateFromFGA(string path)
        {
            var content = File.ReadAllText(path, Encoding.ASCII);
            var values  = content.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            int nx = int.Parse(values[0]);
            int ny = int.Parse(values[1]);
            int nz = int.Parse(values[2]);

            Vec3d p0 = new Vec3d(
                double.Parse(values[3]),
                double.Parse(values[4]),
                double.Parse(values[5]));

            Vec3d p1 = new Vec3d(
                double.Parse(values[6]),
                double.Parse(values[7]),
                double.Parse(values[8]));

            GridVectorField3d result = new GridVectorField3d(new Interval3d(p0, p1), nx, ny, nz);
            var vecs  = result.Values;
            int index = 0;

            for (int i = 9; i < values.Length; i += 3)
            {
                vecs[index++] = new Vec3d(
                    double.Parse(values[i]),
                    double.Parse(values[i + 1]),
                    double.Parse(values[i + 2]));
            }

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parallel"></param>
        /// <returns></returns>
        public GridVectorField3d GetCurl(bool parallel = false)
        {
            GridVectorField3d result = new GridVectorField3d((Grid3d)this);

            GetCurl(result.Values, parallel);
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parallel"></param>
        /// <returns></returns>
        public GridVectorField3d GetGradient(bool parallel = false)
        {
            GridVectorField3d result = new GridVectorField3d(this);

            GetGradient(result.Values, parallel);
            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="copyValues"></param>
        /// <returns></returns>
        public GridVectorField3d Duplicate(bool copyValues)
        {
            var result = new GridVectorField3d(this, SampleMode);

            if (copyValues)
            {
                result.Set(this);
            }
            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="bitmaps"></param>
        /// <param name="mapper"></param>
        /// <param name="interval"></param>
        /// <returns></returns>
        public static GridVectorField3d CreateFromImageStack(IList <Bitmap> bitmaps, Func <Color, Vec3d> mapper, Interval3d interval)
        {
            var bmp0 = bitmaps[0];
            int nx   = bmp0.Width;
            int ny   = bmp0.Height;
            int nz   = bitmaps.Count;

            var result = new GridVectorField3d(interval, nx, ny, nz);

            FieldIO.ReadFromImageStack(bitmaps, result, mapper);

            return(result);
        }