示例#1
0
 /// <summary>
 /// Construct a Grid2d from two Grid1ds in the U and V directions
 /// </summary>
 /// <param name="u"></param>1
 /// <param name="v"></param>
 public Grid2d(Grid1d u, Grid1d v)
 {
     this.U = u;
     this.V = v;
     this.U.SetParent(this);
     this.V.SetParent(this);
 }
示例#2
0
 private void InitializeUV(Domain1d uDomain, Domain1d vDomain)
 {
     U = new Grid1d(uDomain);
     U.TopLevelGridChange += TopLevelGridChange;
     V = new Grid1d(vDomain);
     V.TopLevelGridChange += TopLevelGridChange;
 }
示例#3
0
 private void InitializeUV(Domain1d uDomain, Domain1d vDomain)
 {
     U = new Grid1d(uDomain);
     U.SetParent(this);
     V = new Grid1d(vDomain);
     V.SetParent(this);
 }
示例#4
0
 /// <summary>
 /// Create a grid from a list of boundaries and custom U and V grids
 /// </summary>
 /// <param name="boundaries"></param>
 /// <param name="u"></param>
 /// <param name="v"></param>
 public Grid2d(IList <Polygon> boundaries, Grid1d u, Grid1d v)
 {
     this.SetBoundaries(boundaries);
     this.U = u;
     this.V = v;
     this.U.SetParent(this);
     this.V.SetParent(this);
 }
示例#5
0
 /// <summary>
 /// Construct a 1D Grid from another 1D Grid
 /// </summary>
 /// <param name="other"></param>
 public Grid1d(Grid1d other)
 {
     this.curve       = other.curve;
     this.curveDomain = other.curveDomain;
     this.Domain      = other.Domain;
     if (other.Cells != null)
     {
         this.Cells = other.Cells.Select(c => new Grid1d(c)).ToList();
     }
     this.Type = other.Type;
 }
示例#6
0
 /// <summary>
 /// Construct a Grid2d using another Grid2d as the base, but with different Grid1ds as its axes.
 /// </summary>
 /// <param name="other">The Grid2d to base this one on.</param>
 /// <param name="u">The Grid1d representing the U Axis.</param>
 /// <param name="v">The Grid1d representing the V Axis.</param>
 public Grid2d(Grid2d other, Grid1d u, Grid1d v)
 {
     this.U = u;
     this.U.SetParent(this);
     this.UDomainInternal = other.UDomainInternal;
     this.V = v;
     this.V.SetParent(this);
     this.VDomainInternal       = other.VDomainInternal;
     this.Type                  = other.Type;
     this.boundariesInGridSpace = other.boundariesInGridSpace;
     this.fromGrid              = other.fromGrid;
     this.toGrid                = other.toGrid;
 }
示例#7
0
        /// <summary>
        /// Update the 2d grid cells of this grid when its U or V 1d cells change.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TopLevelGridChange(Grid1d sender, EventArgs e)
        {
            if (CellsFlat.Any(c => !c.IsSingleCell))
            {
                throw new Exception("You are trying to modify the U / V dimensions of a grid that already has subdivisions. This is not allowed.");
            }
            Cells = new List <List <Grid2d> >();
            var uCells = U.IsSingleCell ? new List <Grid1d> {
                U
            } : U.Cells;
            var vCells = V.IsSingleCell ? new List <Grid1d> {
                V
            } : V.Cells;

            foreach (var uCell in uCells)
            {
                var column = new List <Grid2d>();
                foreach (var vCell in vCells)
                {
                    var newCell = new Grid2d(uCell.Domain, vCell.Domain);

                    // Map type name from U and V type names. In most cases this
                    // should only be one direction, so we inherit directly.
                    if (uCell.Type != null && vCell.Type != null)
                    {
                        newCell.Type = $"{uCell.Type} / {vCell.Type}";
                    }
                    else if (uCell.Type != null)
                    {
                        newCell.Type = uCell.Type;
                    }
                    else if (vCell.Type != null)
                    {
                        newCell.Type = vCell.Type;
                    }

                    newCell.fromGrid = fromGrid;
                    newCell.toGrid   = toGrid;
                    newCell.boundariesInGridSpace = boundariesInGridSpace;
                    column.Add(newCell);
                }
                Cells.Add(column);
            }
        }
示例#8
0
 public Grid2d(Transform fromGrid, Transform toGrid, Domain1d uDomainInternal, Domain1d vDomainInternal, List <Polygon> boundariesInGridSpace, Grid1d u, Grid1d v, string type, List <IndexedCell> modifiedChildCells)
 {
     this.fromGrid              = fromGrid;
     this.toGrid                = toGrid;
     this.UDomainInternal       = uDomainInternal;
     this.VDomainInternal       = uDomainInternal;
     this.boundariesInGridSpace = boundariesInGridSpace;
     this.U    = u;
     this.V    = v;
     this.Type = type;
     this.U.SetParent(this);
     this.V.SetParent(this);
     if (modifiedChildCells != null)
     {
         this.cells = GetTopLevelCells();
         foreach (var c in modifiedChildCells)
         {
             this.Cells[c.I][c.J] = c.Grid;
         }
     }
 }
示例#9
0
 /// <summary>
 /// Create a grid from a boundary and custom U and V grids
 /// </summary>
 /// <param name="boundary"></param>
 /// <param name="u"></param>
 /// <param name="v"></param>
 /// <returns></returns>
 public Grid2d(Polygon boundary, Grid1d u, Grid1d v) : this(new Polygon[] { boundary }, u, v)
 {
 }