Esempio n. 1
0
        public IesData Parse()
        {
            this.ies = new IesData();
            using (var fs = new FileStream(this.path, FileMode.Open, FileAccess.Read)) {
                using (var reader = new StreamReader(fs)) {
                    ParseIdentifier(reader);
                    ParseKeywords(reader);
                    ParseTilt(reader);
                    ParseLampData(reader);
                    ParseBallastData(reader);
                    ParseAngles(reader, Direction.Vertical);
                    ParseAngles(reader, Direction.Horizontal);
                    ParseCandelas(reader);
                }
            }

            return(this.ies);
        }
Esempio n. 2
0
        static void DisplayIesData(IesData ies)
        {
            System.Console.WriteLine("");

            System.Console.WriteLine("Identifier: " + ies.identifier);
            System.Console.WriteLine("Keywords: ");
            System.Console.WriteLine();
            foreach (var keyword in ies.keywords)
            {
                System.Console.WriteLine(string.Format("   {0,-12} {1}", keyword.Key, keyword.Value));
            }

            System.Console.WriteLine();

            System.Console.WriteLine("Lamp Count: " + ies.lampCount);
            System.Console.WriteLine("Lumens: " + ies.lumensPerLamp);
            System.Console.WriteLine("Multiplier: " + ies.candelaMultiplier);
            System.Console.WriteLine("Vertical Angles: " + ies.verticalAnglesCount);
            System.Console.WriteLine("Horizontal Angles: " + ies.horizontalAnglesCount);
            System.Console.WriteLine("Photometry Type: " + ies.photometryType);
            System.Console.WriteLine("Units: " + ies.units);
            System.Console.WriteLine("Size: " + ies.sizeX + ", " + ies.sizeY + ", " + ies.sizeZ);
            System.Console.WriteLine("BallastFactor: " + ies.ballastFactor);
            System.Console.WriteLine("InputWatts: " + ies.inputWatts);

            System.Console.WriteLine();

            System.Console.WriteLine("Candela Values:");
            System.Console.WriteLine();

            for (int i = 0; i < ies.horizontalAnglesCount; i++)
            {
                for (int j = 0; j < ies.verticalAnglesCount; j++)
                {
                    System.Console.Write(string.Format("{0,5} | ", ies.angleCandelas [i, j].candela));
                }
                System.Console.WriteLine();
            }

            System.Console.WriteLine();
        }
Esempio n. 3
0
        public IesCubemap RenderCubemap(int resolution, IesData iesData)
        {
            IesCubemap cubemap = new IesCubemap(resolution);

            foreach (var kvp in cubemap.textures)
            {
                CubeFace   face    = kvp.Key;
                IesTexture texture = kvp.Value;
                double     offset  = (1 / cubemap.resolution) / 2;
                for (int y = 0; y < cubemap.resolution; y++)
                {
                    double yNorm = (y / cubemap.resolution) + offset;
                    for (int x = 0; x < cubemap.resolution; x++)
                    {
                        double xNorm        = (x / cubemap.resolution) + offset;
                        Vec3   spherePoint  = IesCubemap.CubeToSpherePoint(face, xNorm, yNorm);
                        LatLon latLongPoint = LatLon.FromSpherePoint(spherePoint);
                        double candela      = InterpolatedCandelaFromData(latLongPoint, iesData.angleCandelas);
                        texture.WritePixelIntensity(x, y, candela);
                    }
                }
            }
            return(cubemap);
        }