예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Model" /> class.
        /// </summary>
        /// <param name="buildings">A list of Buildings in the model. (required).</param>
        /// <param name="properties">Extension properties for particular simulation engines (Radiance, EnergyPlus). (required).</param>
        /// <param name="version">Text string for the current version of the schema. (default to &quot;0.0.0&quot;).</param>
        /// <param name="contextShades">A list of ContextShades in the model..</param>
        /// <param name="units">Text indicating the units in which the model geometry exists. This is used to scale the geometry to the correct units for simulation engines like EnergyPlus, which requires all geometry be in meters..</param>
        /// <param name="tolerance">The maximum difference between x, y, and z values at which vertices are considered equivalent. This value should be in the Model units and is used in a variety of checks and operations. A value of 0 will result in bypassing all checks so it is recommended that this always be a positive number when checks have not already been performed on a Model. The default of 0.01 is suitable for models in meters. (default to 0.01D).</param>
        /// <param name="angleTolerance">The max angle difference in degrees that vertices are allowed to differ from one another in order to consider them colinear. This value is used in a variety of checks and operations that can be performed on geometry. A value of 0 will result in no checks and an inability to perform certain operations so it is recommended that this always be a positive number when checks have not already been performed on a given Model. (default to 1.0D).</param>
        /// <param name="identifier">Text string for a unique object ID. This identifier remains constant as the object is mutated, copied, and serialized to different formats (eg. dict, idf, rad). This identifier is also used to reference the object across a Model. It must be &lt; 100 characters and not contain any spaces or special characters. (required).</param>
        /// <param name="displayName">Display name of the object with no character restrictions..</param>
        /// <param name="userData">Optional dictionary of user data associated with the object.All keys and values of this dictionary should be of a standard data type to ensure correct serialization of the object (eg. str, float, int, list)..</param>
        public Model
        (
            string identifier, List <Building> buildings, ModelProperties properties,                                                                                                                                          // Required parameters
            string displayName = default, Object userData = default, string version = "0.0.0", List <ContextShade> contextShades = default, Units units = Units.Meters, double tolerance = 0.01D, double angleTolerance = 1.0D // Optional parameters
        ) : base(identifier: identifier, displayName: displayName, userData: userData)                                                                                                                                         // BaseClass
        {
            // to ensure "buildings" is required (not null)
            this.Buildings = buildings ?? throw new ArgumentNullException("buildings is a required property for Model and cannot be null");
            // to ensure "properties" is required (not null)
            this.Properties = properties ?? throw new ArgumentNullException("properties is a required property for Model and cannot be null");
            // use default value if no "version" provided
            this.Version        = version ?? "0.0.0";
            this.ContextShades  = contextShades;
            this.Units          = units;
            this.Tolerance      = tolerance;
            this.AngleTolerance = angleTolerance;

            // Set non-required readonly properties with defaultValue
            this.Type = "Model";

            // check if object is valid
            if (this.GetType() == typeof(Model))
            {
                this.IsValid(throwException: true);
            }
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Model" /> class.
        /// </summary>
        /// <param name="name">Name of the object used in all simulation engines. Must not contain spaces and use only letters, digits and underscores/dashes. It cannot be longer than 100 characters. (required).</param>
        /// <param name="buildings">A list of Buildings in the model. (required).</param>
        /// <param name="properties">Extension properties for particular simulation engines (Radiance, EnergyPlus). (required).</param>
        /// <param name="displayName">Display name of the object with no restrictions..</param>
        /// <param name="type">type (default to &quot;Model&quot;).</param>
        /// <param name="contextShades">A list of ContextShades in the model..</param>
        /// <param name="northAngle">The clockwise north direction in degrees. (default to 0).</param>
        /// <param name="units">Text indicating the units in which the model geometry exists. This is used to scale the geometry to the correct units for simulation engines like EnergyPlus, which requires all geometry be in meters. (default to UnitsEnum.Meters).</param>
        /// <param name="tolerance">The maximum difference between x, y, and z values at which vertices are considered equivalent. This value should be in the Model units and is used in a variety of checks and operations that can be performed on geometry, such as solving adjacency between Room2Ds. A value of 0 will result in no checks and an inability to perform certain operations. Typical tolerances for builing geometry range from 0.1 to 0.0001 depending on the units of the geometry. (default to 0).</param>
        /// <param name="angleTolerance">The max angle difference in degrees that vertices are allowed to differ from one another in order to consider them colinear. This value is used in a variety of checks and operations that can be performed on geometry. A value of 0 will result in no checks and an inability to perform certain operations. Typical tolerances for builing geometry are often around 1 degree. (default to 0).</param>
        public Model(string name, List <Building> buildings, ModelProperties properties, string displayName = default, string type = "Model", List <ContextShade> contextShades = default, double northAngle = 0, UnitsEnum?units = UnitsEnum.Meters, double tolerance = 0, double angleTolerance = 0)
        {
            // to ensure "name" is required (not null)
            if (name == null)
            {
                throw new InvalidDataException("name is a required property for Model and cannot be null");
            }
            else
            {
                this.Name = name;
            }

            // to ensure "buildings" is required (not null)
            if (buildings == null)
            {
                throw new InvalidDataException("buildings is a required property for Model and cannot be null");
            }
            else
            {
                this.Buildings = buildings;
            }

            // to ensure "properties" is required (not null)
            if (properties == null)
            {
                throw new InvalidDataException("properties is a required property for Model and cannot be null");
            }
            else
            {
                this.Properties = properties;
            }

            this.DisplayName = displayName;
            // use default value if no "type" provided
            if (type == null)
            {
                this.Type = "Model";
            }
            else
            {
                this.Type = type;
            }
            this.ContextShades = contextShades;
            // use default value if no "northAngle" provided
            if (northAngle == null)
            {
                this.NorthAngle = 0;
            }
            else
            {
                this.NorthAngle = northAngle;
            }
            // use default value if no "units" provided
            if (units == null)
            {
                this.Units = UnitsEnum.Meters;
            }
            else
            {
                this.Units = units;
            }
            // use default value if no "tolerance" provided
            if (tolerance == null)
            {
                this.Tolerance = 0;
            }
            else
            {
                this.Tolerance = tolerance;
            }
            // use default value if no "angleTolerance" provided
            if (angleTolerance == null)
            {
                this.AngleTolerance = 0;
            }
            else
            {
                this.AngleTolerance = angleTolerance;
            }
        }