public ElementSetGridRegularBase(ParametersGridRegular grid, ISpatialDefinition spatialDefinition, ElementType elementType)
            : base(spatialDefinition, elementType)
        {
            GridParameters = grid.Clone() as ParametersGridRegular;

            Arguments = new IArgument[] {
                new ArgumentGridRegular(new Identity("Grid Parameters"), GridParameters),
                }.ToList();

            ElementType = ElementType;
        }
        public ElementSetGridRegularPoints()
            : base(new SpatialDefinition(new Describes("Regular Grid Points", "Point set specified on a regular grid"), -1), ElementType.Point)
        {
            GridParameters = new ParametersGridRegular();

            Arguments = new IArgument[] {
                new ArgumentGridRegular(new Identity("Grid Parameters"), GridParameters),
                }.ToList();

            ElementType = ElementType.Point;
        }
        public ElementSetGridRegularPoints(
			ParametersGridRegular grid,
			Located location,
			bool fastN)
            : base(new SpatialDefinition(new Describes("Regular Grid Points", "Point set specified on a regular grid"), -1), ElementType.Point)
        {
            GridParameters = grid.Clone() as ParametersGridRegular;
            PointsLocated = location;
            FastN = fastN;

            ElementCount = PointsLocated == Located.CellCentre
                ? grid.CellCountX * grid.CellCountY
                : (grid.CellCountX + 1) * (grid.CellCountY + 1);

            Caption = string.Format("Regular Grid {0}x{1} ({2}, {3})",
                GridParameters.CellCountX, GridParameters.CellCountY,
                PointsLocated.ToString(), ElementCount.ToString());

            Arguments = new IArgument[] {
                new ArgumentGridRegular(new Identity("Grid Parameters"), GridParameters),
                }.ToList();

            ElementType = ElementType.Point;
        }
        protected IElementSet ConvertElementSet(OpenMI.Standard.IElementSet elementSet1,
            Utilities.Standard1.ExchangeItemV1ModelXml v1Model)
        {
            if (v1Model != null)
            {
                if (elementSet1.GetType().ToString() == "FluidEarth.Sdk.ElementSetGridRegular"
                    && v1Model.UserVariables["ElementType"] == "XYPoint"
                    && v1Model.UserVariables["Storage"] == "RegularGrid")
                {
                    var cellCountX = int.Parse(v1Model.UserVariables["N"]) - 1;
                    var cellCountY = int.Parse(v1Model.UserVariables["M"]) - 1;
                    var originX = double.Parse(v1Model.UserVariables["OriginX"]);
                    var originY = double.Parse(v1Model.UserVariables["OriginY"]);
                    var deltaX = double.Parse(v1Model.UserVariables["dX"]);
                    var deltaY = double.Parse(v1Model.UserVariables["dY"]);

                    var parameters = new ParametersGridRegular(
                        cellCountX, cellCountY,
                        new Coord2d(originX, originY),
                        deltaX, deltaY);

                    bool fastN = v1Model.UserVariables["Packing"] == "FastN";

                    return new ElementSetGridRegularPoints(parameters, ElementSetGridRegularPoints.Located.Node, fastN);
                }
            }

            return new ElementSetUnoptimisedStorage(elementSet1);
        }
        public void Initialise(XElement xElement, IDocumentAccessor accessor)
        {
            xElement = Persistence.ThisOrSingleChild(XName, xElement);

            ISpatialDefinition spatial;
            bool hasZ, hasM;
            ElementType = Persistence.ElementSet.Parse(xElement, accessor, out spatial, out hasZ, out hasM);
            SetSpatial(spatial);
            HasZ = hasZ;
            HasM = hasM;

            Arguments = Persistence.Arguments
                .Parse(xElement, accessor)
                .ToList();

            GridParameters = new ParametersGridRegular();
            GridParameters.Initialise(xElement, accessor);

            ((ArgumentValueGridRegular)Arguments[0]).Value = GridParameters;
        }
        public ElementSetGridRegularNodes(ParametersGridRegular grid)
            : base(grid,
                new SpatialDefinition(new Describes("Regular Grid Nodes", "Point set specified on nodes of a regular grid"), -1),
                ElementType.Point)
        {
            ElementCount = NX * NY;

            Caption = string.Format("Regular Grid Nodes: {0}x{1} = {2}",
                NX, NY, ElementCount.ToString());
        }
        public ElementSetGridRegularCells(ParametersGridRegular grid)
            : base(grid, 
                new SpatialDefinition(new Describes("Regular Grid Cells", "Polygon set specified as a regular grid"), -1), 
                ElementType.Polygon)
        {
            ElementCount = GridParameters.CellCountX * GridParameters.CellCountY;

            Caption = string.Format("Regular Grid Cells: {0}x{1} = {2}",
                GridParameters.CellCountX, GridParameters.CellCountY, ElementCount.ToString());
        }
        public void Initialise(XElement xElement, IDocumentAccessor accessor)
        {
            xElement = Persistence.ThisOrSingleChild(XName, xElement);

            ISpatialDefinition spatial;
            bool hasZ, hasM;
            ElementType = Persistence.ElementSet.Parse(xElement, accessor, out spatial, out hasZ, out hasM);
            SetSpatial(spatial);
            HasZ = hasZ;
            HasM = hasM;

            Arguments = Persistence.Arguments
                .Parse(xElement, accessor)
                .ToList();

            GridParameters = new ParametersGridRegular();
            GridParameters.Initialise(xElement, accessor);

            ((ArgumentValueGridRegular)Arguments[0]).Value = GridParameters;

            FastN = Utilities.Xml.GetAttribute(xElement, "fastN", true);

            ElementCount = PointsLocated == Located.CellCentre
                ? GridParameters.CellCountX * GridParameters.CellCountY
                : (GridParameters.CellCountX + 1) * (GridParameters.CellCountY + 1);
        }