예제 #1
0
        public Scientrace.CircularFresnelPrism parseXFresnelPrism(XElement xprism)
        {
            //check basic prerequisites
            if (xprism.Name.ToString() != "CircularFresnelPrism")
            {
                throw new XMLException("FresnelPrism does not match its name: " + xprism.Name.ToString());
            }
            Scientrace.Location location = this.X.getXVector(xprism.Element("Location")).toLocation();
            Scientrace.Vector   tsurfv1  = this.X.getXVector(xprism.Element("SurfaceVector1"));
            Scientrace.Vector   tsurfv2  = this.X.getXVector(xprism.Element("SurfaceVector2"));

            Scientrace.NonzeroVector surfv1, surfv2, zaxisheight;
            try {
                surfv1      = tsurfv1.tryToNonzeroVector();
                surfv2      = tsurfv2.tryToNonzeroVector();
                zaxisheight = surfv1.crossProduct(tsurfv2).tryToNonzeroVector();
            } catch {
                throw new XMLException("Parsing fresnel prism error: SurfaceVectors1 and 2 may not be zero.");
            }

            Scientrace.Vector tzaxis = this.X.getXVector(xprism.Element("Height"), zaxisheight);
            try {
                zaxisheight = tzaxis.tryToNonzeroVector();
            } catch {
                throw new XMLException("Parsing fresnel prism error: height vector may not be zero.");
            }

            double LongSideAngle  = this.X.getXAngle(xprism.Element("LongSideAngle"));
            double ShortSideAngle = this.X.getXAngle(xprism.Element("ShortSideAngle"));
            int    TeethCount     = this.X.getXInt(xprism.Attribute("TeethCount"));

            Scientrace.MaterialProperties material = new ShadowClassConstruct(this.parentcollection).getXMaterial(xprism);

            /*
             * string materialid = this.X.getXString(xprism.Attribute("Material"));
             * Scientrace.MaterialProperties material = Scientrace.MaterialProperties.FromIdentifier(materialid);
             */
            Scientrace.CircularFresnelPrism tretprism =
                new Scientrace.CircularFresnelPrism(this.parentcollection,
                                                    this.parentcollection.materialproperties, location, surfv1, surfv2, zaxisheight,
                                                    LongSideAngle, ShortSideAngle, TeethCount, material);
            this.addCommonObjectProperties(tretprism, xprism);
            return(tretprism);
        }
예제 #2
0
        public Scientrace.CircularFresnelPrism parseXFresnelPrism(XElement xprism)
        {
            //check basic prerequisites
            if (xprism.Name.ToString() != "CircularFresnelPrism") {
            throw new XMLException("FresnelPrism does not match its name: "+xprism.Name.ToString());
            }
            Scientrace.Location location = this.X.getXVector(xprism.Element("Location")).toLocation();
            Scientrace.Vector tsurfv1 = this.X.getXVector(xprism.Element("SurfaceVector1"));
            Scientrace.Vector tsurfv2 = this.X.getXVector(xprism.Element("SurfaceVector2"));

            Scientrace.NonzeroVector surfv1, surfv2, zaxisheight;
            try {
                surfv1 = tsurfv1.tryToNonzeroVector();
                surfv2 = tsurfv2.tryToNonzeroVector();
                zaxisheight = surfv1.crossProduct(tsurfv2).tryToNonzeroVector();
                } catch {
                throw new XMLException("Parsing fresnel prism error: SurfaceVectors1 and 2 may not be zero.");
                }

            Scientrace.Vector tzaxis = this.X.getXVector(xprism.Element("Height"), zaxisheight);
            try {
                zaxisheight = tzaxis.tryToNonzeroVector();
                } catch {
                throw new XMLException("Parsing fresnel prism error: height vector may not be zero.");
                }

            double LongSideAngle = this.X.getXAngle(xprism.Element("LongSideAngle"));
            double ShortSideAngle = this.X.getXAngle(xprism.Element("ShortSideAngle"));
            int TeethCount = this.X.getXInt(xprism.Attribute("TeethCount"));
            Scientrace.MaterialProperties material = new ShadowClassConstruct(this.parentcollection).getXMaterial(xprism);
            /*
            string materialid = this.X.getXString(xprism.Attribute("Material"));
            Scientrace.MaterialProperties material = Scientrace.MaterialProperties.FromIdentifier(materialid);
            */
            Scientrace.CircularFresnelPrism tretprism =
                new Scientrace.CircularFresnelPrism(this.parentcollection,
                this.parentcollection.materialproperties, location, surfv1, surfv2, zaxisheight,
                LongSideAngle, ShortSideAngle, TeethCount, material);
            this.addCommonObjectProperties(tretprism, xprism);
            return tretprism;
        }