Пример #1
0
        public Scientrace.MaterialProperties getXMaterial(XElement xel)
        {
            string     materialid;
            XAttribute material_attribute = xel.Attribute("Material");
            XElement   xmaterial          = null;

            if (material_attribute == null)
            {
                xmaterial = xel.Element("Material");
                if (xmaterial == null)
                {
                    throw new XMLException("No material defined in XML Element: \n---\n" + xel.ToString() + "\n---");
                }
                materialid = this.X.getXStringByAttribute(xmaterial, "Class");
            }
            else
            {
                materialid = material_attribute.Value;
            }

            if (Scientrace.MaterialProperties.listedIdentifier(materialid))
            {
                return(Scientrace.MaterialProperties.FromIdentifier(materialid));
            }


            switch (materialid)
            {
            case "StaticNTransparant":             //old type I once made... :S fall through to non-typo version
            case "StaticNTransparent":
                double refindex = this.X.getXDouble(xmaterial, "RefractiveIndex");
                Scientrace.StaticNTransparentMaterial matprops = new Scientrace.StaticNTransparentMaterial(refindex);
                matprops.reflects = this.X.getXBool(xmaterial, "Reflects", true);

                return(matprops);

            //break;
            case "NFormula":
                Scientrace.DispersionFormulaDielectricProperties formuladielectric = new Scientrace.DispersionFormulaDielectricProperties();
                formuladielectric.set_user_formula(this.X.getXStringByName(xmaterial, "Formula"));
                formuladielectric.reflects = this.X.getXBool(xmaterial, "Reflects", true);
                return(formuladielectric);

            //break;
            case "StaticReflectingAbsorber":
                Scientrace.StaticReflectingAbsorberMaterial statRefAbsorber = new Scientrace.StaticReflectingAbsorberMaterial();
                statRefAbsorber.setRefractiveIndex(this.X.getXDouble(xmaterial, "RefractiveIndex", 1));
                statRefAbsorber.setReflectionFraction(this.X.getXDouble(xmaterial, "Reflection", 1));
                statRefAbsorber.setAbsorptionFraction(this.X.getXDouble(xmaterial, "Absorption", 0));
                return(statRefAbsorber);

            //break;
            default:
                throw new XMLException("Material Class [" + materialid + "] unknown");
                //break;
            }
        }
Пример #2
0
        public Scientrace.MaterialProperties getXMaterial(XElement xel)
        {
            string materialid;
            XAttribute material_attribute = xel.Attribute("Material");
            XElement xmaterial = null;

            if (material_attribute == null) {
            xmaterial = xel.Element("Material");
            if (xmaterial == null) {
                throw new XMLException("No material defined in XML Element: \n---\n"+xel.ToString()+"\n---");
                }
            materialid = this.X.getXStringByAttribute(xmaterial,"Class");
            } else {
            materialid = material_attribute.Value;
            }

            if (Scientrace.MaterialProperties.listedIdentifier(materialid))
            return Scientrace.MaterialProperties.FromIdentifier(materialid);

            switch (materialid) {
            case "StaticNTransparant": //old type I once made... :S fall through to non-typo version
            case "StaticNTransparent":
                double refindex = this.X.getXDouble(xmaterial, "RefractiveIndex");
                Scientrace.StaticNTransparentMaterial matprops = new Scientrace.StaticNTransparentMaterial(refindex);
                matprops.reflects = this.X.getXBool(xmaterial, "Reflects", true);

                return matprops;
                //break;
            case "NFormula":
                Scientrace.DispersionFormulaDielectricProperties formuladielectric = new Scientrace.DispersionFormulaDielectricProperties();
                formuladielectric.set_user_formula(this.X.getXStringByName(xmaterial, "Formula"));
                formuladielectric.reflects = this.X.getXBool(xmaterial, "Reflects", true);
                return formuladielectric;
                //break;
            case "StaticReflectingAbsorber":
                Scientrace.StaticReflectingAbsorberMaterial statRefAbsorber = new Scientrace.StaticReflectingAbsorberMaterial();
                statRefAbsorber.setRefractiveIndex(this.X.getXDouble(xmaterial, "RefractiveIndex", 1));
                statRefAbsorber.setReflectionFraction(this.X.getXDouble(xmaterial, "Reflection", 1));
                statRefAbsorber.setAbsorptionFraction(this.X.getXDouble(xmaterial, "Absorption", 0));
                return statRefAbsorber;
                //break;
            default:
                throw new XMLException("Material Class ["+materialid+"] unknown");
                //break;
            }
        }