Esempio n. 1
0
        public Scientrace.LightSource setCustomTracesLightFromXData(XElement xlight,
                                                                    Scientrace.Object3dEnvironment env)
        {
            List <Scientrace.Trace> customtraces = new List <Scientrace.Trace>();
            string tag          = "";
            double minintensity = this.X.getXDouble(xlight.Attribute("MinIntensity"), 0.01);             //default minimum intensity for tracing set to 1%

            foreach (XElement xtrace in xlight.Elements("Trace"))
            {
                double wavelength = this.X.getXDouble(xtrace, "Wavelength",
                                                      (this.X.getXDouble(xtrace, "m",
                                                                         ((this.X.getXDouble(xtrace, "nm", -1)) * 1E-9))
                                                      )
                                                      );
                if (wavelength <= 0)
                {
                    throw new XMLException("Error parsing wavelength from CustomTraces Lightsource. XML Source: \n" +
                                           xtrace.ToString());
                }
                double intensity = this.X.getXDouble(xtrace, "Intensity", 1);

                tag = this.X.getXStringByAttribute(xtrace, "Tag");
                Scientrace.Location   loc = this.X.getXLocation(xtrace, "Location");
                Scientrace.UnitVector dir = this.X.getXNzVectorByName(xtrace, "Direction").toUnitVector();
                customtraces.Add(
                    new Scientrace.Trace(wavelength, null, new Scientrace.Line(loc, dir),
                                         env, intensity, intensity)
                    );
            }
            Scientrace.LightSource retlight = new Scientrace.CustomTracesLightSource(env, customtraces);
            if (tag != "")
            {
                retlight.tag = tag;
            }
            retlight.minimum_intensity_fraction = minintensity;

            return(retlight);
        }
Esempio n. 2
0
        public Scientrace.LightSource setCustomTracesLightFromXData(XElement xlight,
												Scientrace.Object3dEnvironment env)
        {
            List <Scientrace.Trace> customtraces = new List<Scientrace.Trace>();
            string tag = "";
            double minintensity = this.X.getXDouble(xlight.Attribute("MinIntensity"), 0.01); //default minimum intensity for tracing set to 1%
            foreach (XElement xtrace in xlight.Elements("Trace")) {
                double wavelength = this.X.getXDouble(xtrace, "Wavelength",
                                        (this.X.getXDouble(xtrace, "m",
                                            ((this.X.getXDouble(xtrace, "nm", -1))*1E-9))
                                            )
                                        );
                if (wavelength <= 0) {
                    throw new XMLException("Error parsing wavelength from CustomTraces Lightsource. XML Source: \n"+
                        xtrace.ToString());
                    }
                double intensity = this.X.getXDouble(xtrace, "Intensity", 1);

                tag = this.X.getXStringByAttribute(xtrace, "Tag");
                Scientrace.Location loc = this.X.getXLocation(xtrace, "Location");
                Scientrace.UnitVector dir = this.X.getXNzVectorByName(xtrace, "Direction").toUnitVector();
                customtraces.Add(
                                 new Scientrace.Trace(wavelength, null, new Scientrace.Line(loc, dir),
                                                      env, intensity, intensity)
                                 );
                }
            Scientrace.LightSource retlight = new Scientrace.CustomTracesLightSource(env, customtraces);
            if (tag != "") {
                retlight.tag = tag;
                }
            retlight.minimum_intensity_fraction = minintensity;

            return retlight;
        }