Exemplo n.º 1
0
        public Scientrace.Rectangle parseXRectangleVectorBasedConstructor(XElement xsc)
        {
            Scientrace.Location location = this.X.getXLocation(xsc.Element("Location"));

            /* OLD method that caused a crashed on zerovectors.
             * Scientrace.NonzeroVector width = this.X.getXNzVector(xsc.Element("Width"));
             * Scientrace.NonzeroVector height = this.X.getXNzVector(xsc.Element("Height")); */

            Scientrace.Vector vwidth  = this.X.getXVector(xsc.Element("Width"));
            Scientrace.Vector vheight = this.X.getXVector(xsc.Element("Height"));
            if (vwidth.length * vheight.length == 0)
            {
                return(null);
            }
            Scientrace.NonzeroVector width  = vwidth.tryToNonzeroVector();
            Scientrace.NonzeroVector height = vheight.tryToNonzeroVector();

            /*string materialid = this.X
             *      .getXString(xsc.Attribute("Material"));
             * Scientrace.MaterialProperties material = Scientrace.MaterialProperties.FromIdentifier(materialid); */
            Scientrace.MaterialProperties material = new ShadowClassConstruct(this.parentcollection).getXMaterial(xsc);
            //Console.WriteLine("MAT CELL: "+material.GetType());
            Scientrace.Rectangle retcel = new Scientrace.Rectangle(this.parentcollection,
                                                                   material, location, width, height);
            this.addCommonObjectProperties(retcel, xsc);
            this.registerObject(xsc, retcel);
            return(retcel);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        public Scientrace.RectangularPrism parseXRectangularPrism(XElement xrectprism)
        {
            //try {
            //Console.WriteLine("Adding Square Prism");
            //check basic prerequisites
            if (xrectprism.Name.ToString() != "RectangularPrism")
            {
                throw new XMLException("RectangularPrism does not match its name: " + xrectprism.Name.ToString());
            }
            Scientrace.Vector width  = this.X.getXVectorByName(xrectprism, "Width");
            Scientrace.Vector length = this.X.getXVectorByName(xrectprism, "Length");
            Scientrace.Vector height = this.X.getXVectorByName(xrectprism, "Height");
            if (width.length * length.length * height.length == 0)
            {
                Console.WriteLine("WARNING: Rectangular Prism " + xrectprism.Attribute("Tag").Value + " has no volume and will " +
                                  "therefor not be created.");
                return(null);
            }
            Scientrace.Location location = null;
            if (xrectprism.Element("Center") == null)
            {
                location = this.X.getXVectorByName(xrectprism, "Location").toLocation();
            }
            else
            {
                location = (this.X.getXVectorByName(xrectprism, "Center") + (width * -0.5) + (length * -0.5) + (height * -0.5))
                           .toLocation();
            }

            Scientrace.MaterialProperties materialprops = this.getXMaterialForObject(xrectprism);

            /*
             * string materialid = this.X.getXStringByAttribute(xrectprism,"Material");
             * Scientrace.MaterialProperties material = Scientrace.MaterialProperties.FromIdentifier(materialid); */
            //tryToNonzeroVector operations below are permitted since the prism has a volume as was tested above.
            Scientrace.RectangularPrism tretprism = new Scientrace.RectangularPrism(this.parentcollection,
                                                                                    materialprops, location, width.tryToNonzeroVector(), height.tryToNonzeroVector(), length.tryToNonzeroVector());
            this.addCommonObjectProperties(tretprism, xrectprism);
            return(tretprism);

            /*	} catch(Exception e) {Console.WriteLine("Couldn't create RectangularPrism: "+this.X.getXString(xrectprism.Attribute("Tag")));
             *              throw(e);
             *      }*/
        }