Ejemplo n.º 1
0
/*
 *              Scientrace.CircularFresnelPrism cprism = new Scientrace.CircularFresnelPrism(env, air,
 *                      new Location(0, 0, 0), new NonzeroVector(prismradius, 0, 0).rotateAboutY(prismAngleRadians),
 *                      new NonzeroVector(0,0, prismradius).rotateAboutY(prismAngleRadians), new NonzeroVector(0, -0.5E-2, 0),
 *                      this.prism_angle*Math.PI/180, (Math.PI/2)-(this.prism_angle*Math.PI/180), dentalcount, pmma);
 *?/
 *
 *      /* Prism and Mirror data from configfile */
        public Scientrace.ParabolicMirror parseXParabolicMirror(XElement xmir)
        {
            Scientrace.UnitVector miraxis = this.X.getXNzVector(xmir.Element("MirrorAxis")).toUnitVector();

            /*string materialid = this.X.getXString(xmir.Attribute("Material"));
             * Scientrace.MaterialProperties material = Scientrace.MaterialProperties.FromIdentifier(materialid);*/
            Scientrace.MaterialProperties material = new ShadowClassConstruct(this.parentcollection).getXMaterial(xmir);
            XMLBorderParser xbp = new XMLBorderParser();

            Scientrace.AbstractGridBorder border = xbp.getXBorder(xmir.Element("Border"));
            Scientrace.ParabolicMirror    tretpmir;
            if (xmir.Attribute("DistanceToMirror") == null)
            {
                double parabolic_constant    = this.X.getXDouble(xmir.Attribute("ParabolicConstant"));
                Scientrace.Location location = this.X.getXLocation(xmir.Element("Location"));
                tretpmir = new Scientrace.ParabolicMirror(
                    this.parentcollection, material, location, miraxis, parabolic_constant, border);
            }
            else
            {
                double distance_to_mirror      = this.X.getXDouble(xmir.Attribute("DistanceToMirror"));
                Scientrace.Location focuspoint = this.X.getXLocation(xmir.Element("FocusPoint"));
//				Console.WriteLine("-->"+focuspoint.tricoshort()+ " / "+ distance_to_mirror+miraxis.tricon()+ " / <---");
                tretpmir = Scientrace.ParabolicMirror.CreateAtFocus(this.parentcollection, material,
                                                                    focuspoint, distance_to_mirror, miraxis, border);
                tretpmir.exportX3Dgridsteps = 64;
            }
            return(tretpmir);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public void parseXObject3dCollectionContent(XElement xcol, Scientrace.Object3dCollection objectcollection)
        {
            if (xcol == null)
            {
                return;
            }
            XMLObject3dParser    o3dp = new XMLObject3dParser(objectcollection);
            ShadowClassConstruct shadowConstructor = new ShadowClassConstruct(objectcollection);

            //PARSE OBJECTS WITHIN COLLECTION HERE
            foreach (XElement xel in xcol.Elements())
            {
                this.parseXObject3d(xel, objectcollection, o3dp, shadowConstructor);
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public Scientrace.Rectangle parseXRectangleCenterConstructor(XElement xsc)
        {
            Scientrace.Location center = this.X.getXLocation(xsc.Element("Center"));
            //Scientrace.Location pointingtowards = this.X.getXLocation(xsc.Element("PointingTowards"));
            Scientrace.Location pointingtowards = this.X.getXLocation(xsc, "PointingTowards", (this.X.getXLocation(xsc, "Normal") + center));

            Scientrace.UnitVector orthogonaldir = this.X.getXVector(xsc.Element("OrthogonalDirection")).tryToUnitVector();
            //double sidelength = this.X.getXDouble(xsc.Attribute("SideLength"));
            double sidelength = this.X.getXDouble(xsc, "SideLength");

            /*string materialid = this.X.getXString(xsc.Attribute("Material"));
             * Scientrace.MaterialProperties material = Scientrace.MaterialProperties.FromIdentifier(materialid); */
            Scientrace.MaterialProperties material = new ShadowClassConstruct(this.parentcollection).getXMaterial(xsc);
            Scientrace.Rectangle          retcel   = new Scientrace.Rectangle(this.parentcollection, material, center,
                                                                              pointingtowards, orthogonaldir, sidelength);
            this.addCommonObjectProperties(retcel, xsc);
            this.registerObject(xsc, retcel);
            return(retcel);
        }
Ejemplo n.º 6
0
        public Scientrace.MaterialProperties getXMaterialForObject(XElement xmaterial)
        {
            ShadowClassConstruct scc = new ShadowClassConstruct(this.parentcollection);
            Scientrace.MaterialProperties matprop = scc.getXMaterial(xmaterial);
            return matprop;
            /*
            string materialid = this.X.getXStringByAttribute(xmaterial,"Class");
            if (Scientrace.MaterialProperties.listedIdentifier(materialid)) {
            return Scientrace.MaterialProperties.FromIdentifier(materialid);
            }

            switch (materialid) {
            case "StaticNTransparant": //old type I once made... :S
            case "StaticNTransparent":
                double refindex = this.X.getXDouble(xmaterial, "RefractiveIndex");
                return new Scientrace.StaticNTransparentMaterial(refindex);
                //break;
            default:
                throw new XMLException("Material Class ["+materialid+"] unknown");
                //break;
            }*/
        }
Ejemplo n.º 7
0
        public Scientrace.MaterialProperties getXMaterialForObject(XElement xmaterial)
        {
            ShadowClassConstruct scc = new ShadowClassConstruct(this.parentcollection);

            Scientrace.MaterialProperties matprop = scc.getXMaterial(xmaterial);
            return(matprop);

            /*
             * string materialid = this.X.getXStringByAttribute(xmaterial,"Class");
             * if (Scientrace.MaterialProperties.listedIdentifier(materialid)) {
             *      return Scientrace.MaterialProperties.FromIdentifier(materialid);
             *      }
             *
             * switch (materialid) {
             *      case "StaticNTransparant": //old type I once made... :S
             *      case "StaticNTransparent":
             *              double refindex = this.X.getXDouble(xmaterial, "RefractiveIndex");
             *              return new Scientrace.StaticNTransparentMaterial(refindex);
             *              //break;
             *      default:
             *              throw new XMLException("Material Class ["+materialid+"] unknown");
             *              //break;
             *      }*/
        }
Ejemplo n.º 8
0
        public void parseXObject3d(XElement xel, Scientrace.Object3dCollection col, XMLObject3dParser o3dp, ShadowClassConstruct shadowConstructor)
        {
            Scientrace.Object3d createdObject3d = null;
            switch (xel.Name.ToString())
            {
            case "CircularFresnelPrism":
                createdObject3d = o3dp.parseXFresnelPrism(xel);
                break;

            case "ParabolicMirror":
                createdObject3d = o3dp.parseXParabolicMirror(xel);
                //PARSE PARAB MIRROR
                break;

            case "Prism":             //fall through
            case "TriangularPrism":
                createdObject3d = shadowConstructor.constructTriangularPrism(xel);
                //createdObject3d = o3dp.parseXTriangularPrism(xel);
                break;

            case "RectangularPrism":
                createdObject3d = o3dp.parseXRectangularPrism(xel);
                break;

            case "SquareCell":
            case "Rectangle":
                //square cell can be used for any square or rectangular surface-object
                //createdObject3d = o3dp.parseXRectangle(xel);
                createdObject3d = shadowConstructor.constructRectangle(xel);
                break;

            case "Sphere":
                createdObject3d = o3dp.parseXSphere(xel);
                break;

            case "FresnelLens":
                createdObject3d = shadowConstructor.constructFresnelLens(xel);
                break;

            case "FresnelLensRing":
                createdObject3d = shadowConstructor.constructFresnelLensRing(xel);
                break;

            case "PlanoConvexLens":
                createdObject3d = o3dp.parseXPlanoConvexLens(xel);
                break;

            case "DoubleConvexLens":
                //createdObject3d = o3dp.parseXDoubleConvexLens(xel);
                createdObject3d = shadowConstructor.constructDoubleConvexLens(xel);
                break;

            case "BorderedVolume":
                createdObject3d = o3dp.parsXBorderedVolume(xel);
                break;

            case "ToppedPyramid":
            case "TruncatedPyramid":
                createdObject3d = o3dp.parseXTruncatedPyramid(xel);
                break;

            case "CameraViewpoint":        //fallthrough
            case "CameraFrom":             //fallthrough
            case "CameraRotation":
                //Cam settings set at environment.
                break;

            case "LightSource":
                //do nothing, already parsed previously
                break;

            case "Ignore":
            case "IGNORE":
                //do nothing, IGNORE!
                break;

            default:
                if (!(xel.Name.ToString().Substring(0, 3) == "REM"))
                {
                    Console.WriteLine("WARNING: UNKNOWN OBJECT: " + xel.Name + " \n[XML code]\n" + xel.ToString() + "\n[/XML code]\n");
                }
                break;
            }
            if (createdObject3d != null)
            {
                XMLTraceModifierParser xtmp = new XMLTraceModifierParser();
                List <Scientrace.UniformTraceModifier> utms = xtmp.getModifiers(xel);
                createdObject3d.addSurfaceModifiers(utms);
            }
        }         // end parseXObject3d
Ejemplo n.º 9
0
        public void parseXObject3dCollectionContent(XElement xcol, Scientrace.Object3dCollection objectcollection)
        {
            if (xcol == null) return;
            XMLObject3dParser o3dp = new XMLObject3dParser(objectcollection);
            ShadowClassConstruct shadowConstructor = new ShadowClassConstruct(objectcollection);

            //PARSE OBJECTS WITHIN COLLECTION HERE
            foreach (XElement xel in xcol.Elements())
            this.parseXObject3d(xel, objectcollection, o3dp, shadowConstructor);
        }
Ejemplo n.º 10
0
 public void parseXObject3d(XElement xel, Scientrace.Object3dCollection col, XMLObject3dParser o3dp, ShadowClassConstruct shadowConstructor)
 {
     Scientrace.Object3d createdObject3d = null;
     switch (xel.Name.ToString()) {
     case "CircularFresnelPrism":
         createdObject3d = o3dp.parseXFresnelPrism(xel);
         break;
     case "ParabolicMirror":
         createdObject3d = o3dp.parseXParabolicMirror(xel);
         //PARSE PARAB MIRROR
         break;
     case "Prism": //fall through
     case "TriangularPrism":
         createdObject3d = shadowConstructor.constructTriangularPrism(xel);
         //createdObject3d = o3dp.parseXTriangularPrism(xel);
         break;
     case "RectangularPrism":
         createdObject3d = o3dp.parseXRectangularPrism(xel);
         break;
     case "SquareCell":
     case "Rectangle":
         //square cell can be used for any square or rectangular surface-object
         //createdObject3d = o3dp.parseXRectangle(xel);
         createdObject3d = shadowConstructor.constructRectangle(xel);
         break;
     case "Sphere":
         createdObject3d = o3dp.parseXSphere(xel);
         break;
     case "FresnelLens":
         createdObject3d = shadowConstructor.constructFresnelLens(xel);
         break;
     case "FresnelLensRing":
         createdObject3d = shadowConstructor.constructFresnelLensRing(xel);
         break;
     case "PlanoConvexLens":
         createdObject3d = o3dp.parseXPlanoConvexLens(xel);
         break;
     case "DoubleConvexLens":
         //createdObject3d = o3dp.parseXDoubleConvexLens(xel);
         createdObject3d = shadowConstructor.constructDoubleConvexLens(xel);
         break;
     case "BorderedVolume":
         createdObject3d = o3dp.parsXBorderedVolume(xel);
         break;
     case "ToppedPyramid":
     case "TruncatedPyramid":
         createdObject3d = o3dp.parseXTruncatedPyramid(xel);
         break;
     case "CameraViewpoint": //fallthrough
     case "CameraFrom": //fallthrough
     case "CameraRotation":
         //Cam settings set at environment.
         break;
     case "LightSource":
         //do nothing, already parsed previously
         break;
     case "Ignore":
     case "IGNORE":
         //do nothing, IGNORE!
         break;
     default:
         if (!(xel.Name.ToString().Substring(0,3)=="REM")) {
             Console.WriteLine("WARNING: UNKNOWN OBJECT: "+xel.Name+" \n[XML code]\n"+xel.ToString()+"\n[/XML code]\n");
             }
         break;
     }
     if (createdObject3d != null) {
     XMLTraceModifierParser xtmp = new XMLTraceModifierParser();
     List<Scientrace.UniformTraceModifier> utms = xtmp.getModifiers(xel);
     createdObject3d.addSurfaceModifiers(utms);
     }
 }
Ejemplo n.º 11
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;
        }
Ejemplo n.º 12
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;
        }
Ejemplo n.º 13
0
        public Scientrace.Rectangle parseXRectangleCenterConstructor(XElement xsc)
        {
            Scientrace.Location center = this.X.getXLocation(xsc.Element("Center"));
            //Scientrace.Location pointingtowards = this.X.getXLocation(xsc.Element("PointingTowards"));
            Scientrace.Location pointingtowards = this.X.getXLocation(xsc, "PointingTowards", (this.X.getXLocation(xsc, "Normal")+center));

            Scientrace.UnitVector orthogonaldir = this.X.getXVector(xsc.Element("OrthogonalDirection")).tryToUnitVector();
            //double sidelength = this.X.getXDouble(xsc.Attribute("SideLength"));
            double sidelength = this.X.getXDouble(xsc, "SideLength");
            /*string materialid = this.X.getXString(xsc.Attribute("Material"));
            Scientrace.MaterialProperties material = Scientrace.MaterialProperties.FromIdentifier(materialid); */
            Scientrace.MaterialProperties material = new ShadowClassConstruct(this.parentcollection).getXMaterial(xsc);
            Scientrace.Rectangle retcel = new Scientrace.Rectangle(this.parentcollection, material, center,
                                          pointingtowards, orthogonaldir, sidelength);
            this.addCommonObjectProperties(retcel, xsc);
            this.registerObject(xsc, retcel);
            return retcel;
        }
Ejemplo n.º 14
0
        /*
        Scientrace.CircularFresnelPrism cprism = new Scientrace.CircularFresnelPrism(env, air,
            new Location(0, 0, 0), new NonzeroVector(prismradius, 0, 0).rotateAboutY(prismAngleRadians),
            new NonzeroVector(0,0, prismradius).rotateAboutY(prismAngleRadians), new NonzeroVector(0, -0.5E-2, 0),
            this.prism_angle*Math.PI/180, (Math.PI/2)-(this.prism_angle*Math.PI/180), dentalcount, pmma);
         *?/

        /* Prism and Mirror data from configfile */
        public Scientrace.ParabolicMirror parseXParabolicMirror(XElement xmir)
        {
            Scientrace.UnitVector miraxis = this.X.getXNzVector(xmir.Element("MirrorAxis")).toUnitVector();

            /*string materialid = this.X.getXString(xmir.Attribute("Material"));
            Scientrace.MaterialProperties material = Scientrace.MaterialProperties.FromIdentifier(materialid);*/
            Scientrace.MaterialProperties material = new ShadowClassConstruct(this.parentcollection).getXMaterial(xmir);
            XMLBorderParser xbp = new XMLBorderParser();
            Scientrace.AbstractGridBorder border = xbp.getXBorder(xmir.Element("Border"));
            Scientrace.ParabolicMirror tretpmir;
            if (xmir.Attribute("DistanceToMirror") == null) {
                double parabolic_constant = this.X.getXDouble(xmir.Attribute("ParabolicConstant"));
                Scientrace.Location location = this.X.getXLocation(xmir.Element("Location"));
                tretpmir = new Scientrace.ParabolicMirror(
                    this.parentcollection, material, location, miraxis, parabolic_constant, border);
                } else {
                double distance_to_mirror = this.X.getXDouble(xmir.Attribute("DistanceToMirror"));
                Scientrace.Location focuspoint = this.X.getXLocation(xmir.Element("FocusPoint"));
            //				Console.WriteLine("-->"+focuspoint.tricoshort()+ " / "+ distance_to_mirror+miraxis.tricon()+ " / <---");
                tretpmir = Scientrace.ParabolicMirror.CreateAtFocus(this.parentcollection, material,
                                focuspoint, distance_to_mirror, miraxis, border);
                tretpmir.exportX3Dgridsteps = 64;
                }
            return tretpmir;
        }