예제 #1
0
파일: Reader.cs 프로젝트: dorchard/mucell
        public void CompartmentElement(Hashtable attrs)
        {
            Compartment compartment = new Compartment(this.model, attrs);

            CompartmentType compartmentType = null;
            int spatialDimensions = 3;
            double size = 1;
            String units = null; // unit enum or user-defined unit
            Compartment outside = null;
            Boolean constant = true;

            if (attrs.Contains("constant"))
            constant = Boolean.Parse((String)attrs["units"]);
            if (attrs.Contains("spatialdimensions"))
            spatialDimensions = (int)(Int32.Parse((String)attrs["spatialdimensions"]));
            if (attrs.Contains("size"))
            size = (double)(Double.Parse((String)attrs["size"]));
            else if (attrs.Contains("volume")) // from SBML Level 1
            size = (double)(Double.Parse((String)attrs["volume"]));
            if (attrs.Contains("units") && this.model.IsUnits((String)attrs["units"]))
            units = (String)attrs["units"];
            else
            {
            switch (spatialDimensions)
            {
                case 1:
                    units = "length";
                    break;
                case 2:
                    units = "area";
                    break;
                case 3:
                    units = "volume";
                    break;
            }
            }

            if (attrs.Contains("compartmenttype"))
            {
            String cTypeId = (String)attrs["compartmenttype"];
            compartmentType = (CompartmentType)this.model.findObject(cTypeId);
            }
            if (attrs.Contains("outside"))
            {
            String cId = (String)attrs["outside"];
            outside = (Compartment)this.model.findObject(cId);
            }

            compartment.AddProperties(compartmentType, spatialDimensions, size,
            units, outside, constant);

            this.model.listOfCompartments.Add(compartment);
        }