Last active
January 11, 2016 15:19
-
-
Save holg/aec5a0e19111b9d7177e to your computer and use it in GitHub Desktop.
JSIL_ies_tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Generated by JSIL v0.8.2 build 13182. See http://jsil.org/ for more information. | |
| 'use strict'; | |
| var $asm00 = JSIL.GetAssembly("427c5300, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"); | |
| var $asm01 = JSIL.GetAssembly("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); | |
| /* Generated by JSIL v0.8.2 build 13182. See http://jsil.org/ for more information. */ | |
| 'use strict'; | |
| var $asm00 = JSIL.DeclareAssembly("427c5300, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"); | |
| JSIL.SetEntryPoint($asm00, $asm00.TypeRef("IESTools.MainClass"), "Main", JSIL.MethodSignature.Action($jsilcore.TypeRef("System.Array", [$asm01.TypeRef("System.String")]))); | |
| JSIL.DeclareNamespace("IESTools"); | |
| /* struct IESTools.RGBEPixel */ | |
| (function RGBEPixel$Members () { | |
| var $, $thisType; | |
| var $T00 = function () { | |
| return ($T00 = JSIL.Memoize($asm01.System.Single)) (); | |
| }; | |
| var $T01 = function () { | |
| return ($T01 = JSIL.Memoize($asm01.System.Int32)) (); | |
| }; | |
| var $T02 = function () { | |
| return ($T02 = JSIL.Memoize($asm01.System.Byte)) (); | |
| }; | |
| var $T03 = function () { | |
| return ($T03 = JSIL.Memoize($asm01.System.Object)) (); | |
| }; | |
| var $T04 = function () { | |
| return ($T04 = JSIL.Memoize($asm01.System.Boolean)) (); | |
| }; | |
| function RGBEPixel__ctor (r, g, b) { | |
| var exponent = new JSIL.BoxedVariable(0); | |
| var val = +r; | |
| if (+g > val) { | |
| val = +g; | |
| } | |
| if (+b > val) { | |
| val = +b; | |
| } | |
| if (val < 1E-32) { | |
| this.r = this.g = this.b = this.e = 0; | |
| } else { | |
| val = +(((+$thisType.Frexp(val, /* ref */ exponent) * 256) / val)); | |
| this.r = ((+r * val) | 0); | |
| this.g = ((+g * val) | 0); | |
| this.b = ((+b * val) | 0); | |
| this.e = ((((exponent.get() | 0) + 128) | 0) & 0xFF); | |
| } | |
| }; | |
| function RGBEPixel_Object_Equals (obj) { | |
| if (obj === null) { | |
| var result = false; | |
| } else if (!$thisType.$Is(obj)) { | |
| result = false; | |
| } else { | |
| var p = $thisType.$Cast(obj); | |
| result = !(((p.r | 0) !== (this.r | 0)) || | |
| ((p.g | 0) !== (this.g | 0)) || | |
| ((p.b | 0) !== (this.b | 0))) && | |
| ((p.e | 0) === (this.e | 0)); | |
| } | |
| return result; | |
| }; | |
| function RGBEPixel_Frexp (value, /* ref */ exponent) { | |
| exponent.set(1); | |
| return 1; | |
| }; | |
| function RGBEPixel_GetHashCode () { | |
| return ((((this.r | 0) ^ (this.g | 0)) ^ (this.b | 0)) ^ (this.e | 0)); | |
| }; | |
| function RGBEPixel_op_Equality (a, b) { | |
| return (false || ((a !== null) && | |
| (b !== null) && | |
| !(((a.r | 0) !== (b.r | 0)) || | |
| ((a.g | 0) !== (b.g | 0)) || | |
| ((a.b | 0) !== (b.b | 0))) && | |
| ((a.e | 0) === (b.e | 0)))); | |
| }; | |
| function RGBEPixel_op_Inequality (a, b) { | |
| return !$thisType.op_Equality(a, b); | |
| }; | |
| JSIL.MakeType({ | |
| BaseType: $asm01.TypeRef("System.ValueType"), | |
| Name: "IESTools.RGBEPixel", | |
| IsPublic: true, | |
| IsReferenceType: false, | |
| MaximumConstructorArguments: 3, | |
| SequentialLayout: true, | |
| }, function ($interfaceBuilder) { | |
| $ = $interfaceBuilder; | |
| $.Method({Static:false, Public:true }, ".ctor", | |
| new JSIL.MethodSignature(null, [ | |
| $.Single, $.Single, | |
| $.Single | |
| ]), | |
| RGBEPixel__ctor | |
| ); | |
| $.Method({Static:false, Public:true , Virtual:true }, "Object.Equals", | |
| new JSIL.MethodSignature($.Boolean, [$.Object]), | |
| RGBEPixel_Object_Equals | |
| ); | |
| $.Method({Static:true , Public:false}, "Frexp", | |
| new JSIL.MethodSignature($.Single, [$.Single, $jsilcore.TypeRef("JSIL.Reference", [$.Int32])]), | |
| RGBEPixel_Frexp | |
| ); | |
| $.Method({Static:false, Public:true , Virtual:true }, "GetHashCode", | |
| JSIL.MethodSignature.Return($.Int32), | |
| RGBEPixel_GetHashCode | |
| ); | |
| $.Method({Static:true , Public:true }, "op_Equality", | |
| new JSIL.MethodSignature($.Boolean, [$.Type, $.Type]), | |
| RGBEPixel_op_Equality | |
| ); | |
| $.Method({Static:true , Public:true }, "op_Inequality", | |
| new JSIL.MethodSignature($.Boolean, [$.Type, $.Type]), | |
| RGBEPixel_op_Inequality | |
| ); | |
| $.Field({Static:false, Public:true }, "r", $.Byte); | |
| $.Field({Static:false, Public:true }, "g", $.Byte); | |
| $.Field({Static:false, Public:true }, "b", $.Byte); | |
| $.Field({Static:false, Public:true }, "e", $.Byte); | |
| return function (newThisType) { $thisType = newThisType; }; | |
| }); | |
| })(); | |
| /* class IESTools.RGBEFile */ | |
| (function RGBEFile$Members () { | |
| var $, $thisType; | |
| var $T00 = function () { | |
| return ($T00 = JSIL.Memoize($asm00.IESTools.IesTexture)) (); | |
| }; | |
| var $T01 = function () { | |
| return ($T01 = JSIL.Memoize($asm01.System.Text.StringBuilder)) (); | |
| }; | |
| var $T02 = function () { | |
| return ($T02 = JSIL.Memoize($asm01.System.String)) (); | |
| }; | |
| var $T03 = function () { | |
| return ($T03 = JSIL.Memoize(System.Array.Of($asm01.System.Char))) (); | |
| }; | |
| var $T04 = function () { | |
| return ($T04 = JSIL.Memoize($asm01.System.Char)) (); | |
| }; | |
| var $T05 = function () { | |
| return ($T05 = JSIL.Memoize($asm01.System.Int32)) (); | |
| }; | |
| var $T06 = function () { | |
| return ($T06 = JSIL.Memoize($asm01.System.Byte)) (); | |
| }; | |
| var $S00 = function () { | |
| return ($S00 = JSIL.Memoize(new JSIL.ConstructorSignature($asm01.TypeRef("System.Text.StringBuilder"), null))) (); | |
| }; | |
| var $S01 = function () { | |
| return ($S01 = JSIL.Memoize(new JSIL.MethodSignature($asm01.TypeRef("System.Text.StringBuilder"), [ | |
| $asm01.TypeRef("System.String"), $asm01.TypeRef("System.Object"), | |
| $asm01.TypeRef("System.Object") | |
| ]))) (); | |
| }; | |
| function RGBEFile__ctor (texture) { | |
| this.texture = texture; | |
| }; | |
| function RGBEFile_GetBytes () { | |
| var sb = $S00().Construct(); | |
| sb.AppendLine("#?RADIANCE"); | |
| if (!$T02().IsNullOrEmpty(this.creatorName)) { | |
| sb.AppendLine(JSIL.ConcatString("# Made with ", this.creatorName)); | |
| } | |
| sb.AppendLine("FORMAT=32-bit_rle_rgbe"); | |
| $S01().CallVirtual("AppendFormat", null, sb, "-Y {0} +X {1}", this.texture.IesTexture$Width$value, this.texture.IesTexture$Height$value); | |
| sb.AppendLine(); | |
| var data = JSIL.Array.New($T04(), sb.get_Length()); | |
| sb.CopyTo(0, data, 0, sb.get_Length()); | |
| for (var y = 0; y < (this.texture.IesTexture$Height$value | 0); y = ((y + 1) | 0)) { | |
| for (var x = 0; x < (this.texture.IesTexture$Width$value | 0); x = ((x + 1) | 0)) { | |
| if (!((x <= 0) || (+(this.texture).ReadPixelIntensity(((x - 1) | 0), y) !== +(this.texture).ReadPixelIntensity(x, y)))) { | |
| } | |
| } | |
| } | |
| return JSIL.Array.New($T06(), 0); | |
| }; | |
| JSIL.MakeType({ | |
| BaseType: $asm01.TypeRef("System.Object"), | |
| Name: "IESTools.RGBEFile", | |
| IsPublic: true, | |
| IsReferenceType: true, | |
| MaximumConstructorArguments: 1, | |
| }, function ($interfaceBuilder) { | |
| $ = $interfaceBuilder; | |
| $.Method({Static:false, Public:true }, ".ctor", | |
| JSIL.MethodSignature.Action($asm00.TypeRef("IESTools.IesTexture")), | |
| RGBEFile__ctor | |
| ); | |
| $.Method({Static:false, Public:true }, "GetBytes", | |
| JSIL.MethodSignature.Return($jsilcore.TypeRef("System.Array", [$.Byte])), | |
| RGBEFile_GetBytes | |
| ); | |
| $.Field({Static:false, Public:true }, "creatorName", $.String); | |
| $.Field({Static:false, Public:false}, "texture", $asm00.TypeRef("IESTools.IesTexture")); | |
| return function (newThisType) { $thisType = newThisType; }; | |
| }); | |
| })(); | |
| /* class IESTools.IesTexture */ | |
| (function IesTexture$Members () { | |
| var $, $thisType; | |
| var $T00 = function () { | |
| return ($T00 = JSIL.Memoize($asm01.System.Int32)) (); | |
| }; | |
| var $T01 = function () { | |
| return ($T01 = JSIL.Memoize($asm01.System.Double)) (); | |
| }; | |
| var $T02 = function () { | |
| return ($T02 = JSIL.Memoize(System.Array.Of($asm01.System.Double))) (); | |
| }; | |
| function IesTexture__ctor (width, height) { | |
| this.IesTexture$Width$value = (width | 0); | |
| this.IesTexture$Height$value = (height | 0); | |
| this.intensities = JSIL.MultidimensionalArray.New($T01(), width, height); | |
| }; | |
| function IesTexture_get_Height () { | |
| return this.IesTexture$Height$value; | |
| }; | |
| function IesTexture_get_Width () { | |
| return this.IesTexture$Width$value; | |
| }; | |
| function IesTexture_ReadPixelIntensity (x, y) { | |
| return (this.intensities).Get(x, y); | |
| }; | |
| function IesTexture_set_Height (value) { | |
| this.IesTexture$Height$value = (value | 0); | |
| }; | |
| function IesTexture_set_Width (value) { | |
| this.IesTexture$Width$value = (value | 0); | |
| }; | |
| function IesTexture_WritePixelIntensity (x, y, intensity) { | |
| (this.intensities).Set(x, y, intensity); | |
| }; | |
| JSIL.MakeType({ | |
| BaseType: $asm01.TypeRef("System.Object"), | |
| Name: "IESTools.IesTexture", | |
| IsPublic: true, | |
| IsReferenceType: true, | |
| MaximumConstructorArguments: 2, | |
| }, function ($interfaceBuilder) { | |
| $ = $interfaceBuilder; | |
| $.Method({Static:false, Public:true }, ".ctor", | |
| new JSIL.MethodSignature(null, [$.Int32, $.Int32]), | |
| IesTexture__ctor | |
| ); | |
| $.Method({Static:false, Public:true }, "get_Height", | |
| JSIL.MethodSignature.Return($.Int32), | |
| IesTexture_get_Height | |
| ) | |
| .Attribute($asm01.TypeRef("System.Runtime.CompilerServices.CompilerGeneratedAttribute")); | |
| $.Method({Static:false, Public:true }, "get_Width", | |
| JSIL.MethodSignature.Return($.Int32), | |
| IesTexture_get_Width | |
| ) | |
| .Attribute($asm01.TypeRef("System.Runtime.CompilerServices.CompilerGeneratedAttribute")); | |
| $.Method({Static:false, Public:true }, "ReadPixelIntensity", | |
| new JSIL.MethodSignature($.Double, [$.Int32, $.Int32]), | |
| IesTexture_ReadPixelIntensity | |
| ); | |
| $.Method({Static:false, Public:false}, "set_Height", | |
| JSIL.MethodSignature.Action($.Int32), | |
| IesTexture_set_Height | |
| ) | |
| .Attribute($asm01.TypeRef("System.Runtime.CompilerServices.CompilerGeneratedAttribute")); | |
| $.Method({Static:false, Public:false}, "set_Width", | |
| JSIL.MethodSignature.Action($.Int32), | |
| IesTexture_set_Width | |
| ) | |
| .Attribute($asm01.TypeRef("System.Runtime.CompilerServices.CompilerGeneratedAttribute")); | |
| $.Method({Static:false, Public:true }, "WritePixelIntensity", | |
| new JSIL.MethodSignature(null, [ | |
| $.Int32, $.Int32, | |
| $.Double | |
| ]), | |
| IesTexture_WritePixelIntensity | |
| ); | |
| $.Field({Static:false, Public:false}, "IesTexture$Width$value", $.Int32) | |
| .Attribute($asm01.TypeRef("System.Runtime.CompilerServices.CompilerGeneratedAttribute")); | |
| $.Field({Static:false, Public:false}, "IesTexture$Height$value", $.Int32) | |
| .Attribute($asm01.TypeRef("System.Runtime.CompilerServices.CompilerGeneratedAttribute")); | |
| $.Field({Static:false, Public:false}, "intensities", $jsilcore.TypeRef("System.Array", [$.Double])); | |
| $.Property({Static:false, Public:true }, "Width", $.Int32); | |
| $.Property({Static:false, Public:true }, "Height", $.Int32); | |
| return function (newThisType) { $thisType = newThisType; }; | |
| }); | |
| })(); | |
| /* class IESTools.IesRenderer */ | |
| (function IesRenderer$Members () { | |
| var $, $thisType; | |
| var $T00 = function () { | |
| return ($T00 = JSIL.Memoize($asm00.IESTools.LatLon)) (); | |
| }; | |
| var $T01 = function () { | |
| return ($T01 = JSIL.Memoize(System.Array.Of($asm00.IESTools.AngleCandela))) (); | |
| }; | |
| var $T02 = function () { | |
| return ($T02 = JSIL.Memoize($asm01.System.Int32)) (); | |
| }; | |
| var $T03 = function () { | |
| return ($T03 = JSIL.Memoize($asm00.IESTools.IesData)) (); | |
| }; | |
| var $T04 = function () { | |
| return ($T04 = JSIL.Memoize($asm00.IESTools.IesCubemap)) (); | |
| }; | |
| var $T05 = function () { | |
| return ($T05 = JSIL.Memoize($asm01.System.Collections.Generic.Dictionary$b2_Enumerator.Of($asm00.IESTools.CubeFace, $asm00.IESTools.IesTexture))) (); | |
| }; | |
| var $T06 = function () { | |
| return ($T06 = JSIL.Memoize($asm01.System.Collections.Generic.Dictionary$b2.Of($asm00.IESTools.CubeFace, $asm00.IESTools.IesTexture))) (); | |
| }; | |
| var $T07 = function () { | |
| return ($T07 = JSIL.Memoize($asm01.System.Collections.Generic.KeyValuePair$b2.Of($asm00.IESTools.CubeFace, $asm00.IESTools.IesTexture))) (); | |
| }; | |
| var $T08 = function () { | |
| return ($T08 = JSIL.Memoize($asm00.IESTools.CubeFace)) (); | |
| }; | |
| var $T09 = function () { | |
| return ($T09 = JSIL.Memoize($asm00.IESTools.IesTexture)) (); | |
| }; | |
| var $T0A = function () { | |
| return ($T0A = JSIL.Memoize($asm01.System.Double)) (); | |
| }; | |
| var $T0B = function () { | |
| return ($T0B = JSIL.Memoize($asm00.IESTools.Vec3)) (); | |
| }; | |
| var $S00 = function () { | |
| return ($S00 = JSIL.Memoize(new JSIL.MethodSignature($asm00.TypeRef("IESTools.Vec3"), [ | |
| $asm00.TypeRef("IESTools.CubeFace"), $asm01.TypeRef("System.Double"), | |
| $asm01.TypeRef("System.Double") | |
| ]))) (); | |
| }; | |
| function IesRenderer__ctor () { | |
| }; | |
| function IesRenderer_InterpolatedCandelaFromData (position, data) { | |
| return 0; | |
| }; | |
| function IesRenderer_RenderCubemap (resolution, iesData) { | |
| var cubemap = new ($T04())(resolution); | |
| var enumerator = $T06().prototype.GetEnumerator.call(cubemap.textures); | |
| while ($T05().prototype.MoveNext.call(enumerator)) { | |
| var kvp = $T05().prototype.get_Current.call(enumerator); | |
| var face = kvp.get_Key(); | |
| var texture = kvp.get_Value(); | |
| var offset = +((((1 / (cubemap.resolution | 0)) | 0) / 2 | 0)); | |
| for (var y = 0; y < (cubemap.resolution | 0); y = ((y + 1) | 0)) { | |
| var yNorm = +((y / (cubemap.resolution | 0) | 0)) + offset; | |
| for (var x = 0; x < (cubemap.resolution | 0); x = ((x + 1) | 0)) { | |
| var xNorm = +((x / (cubemap.resolution | 0) | 0)) + offset; | |
| var spherePoint = $S00().CallStatic($T04(), "CubeToSpherePoint", null, face, xNorm, yNorm).MemberwiseClone(); | |
| var latLongPoint = $T00().FromSpherePoint(spherePoint.MemberwiseClone(), 1); | |
| var candela = +this.InterpolatedCandelaFromData(latLongPoint, iesData.angleCandelas); | |
| texture.WritePixelIntensity(x, y, candela); | |
| } | |
| } | |
| } | |
| return cubemap; | |
| }; | |
| JSIL.MakeType({ | |
| BaseType: $asm01.TypeRef("System.Object"), | |
| Name: "IESTools.IesRenderer", | |
| IsPublic: true, | |
| IsReferenceType: true, | |
| MaximumConstructorArguments: 0, | |
| }, function ($interfaceBuilder) { | |
| $ = $interfaceBuilder; | |
| $.Method({Static:false, Public:true }, ".ctor", | |
| JSIL.MethodSignature.Void, | |
| IesRenderer__ctor | |
| ); | |
| $.Method({Static:false, Public:false}, "InterpolatedCandelaFromData", | |
| new JSIL.MethodSignature($.Double, [$asm00.TypeRef("IESTools.LatLon"), $jsilcore.TypeRef("System.Array", [$asm00.TypeRef("IESTools.AngleCandela")])]), | |
| IesRenderer_InterpolatedCandelaFromData | |
| ); | |
| $.Method({Static:false, Public:true }, "RenderCubemap", | |
| new JSIL.MethodSignature($asm00.TypeRef("IESTools.IesCubemap"), [$.Int32, $asm00.TypeRef("IESTools.IesData")]), | |
| IesRenderer_RenderCubemap | |
| ); | |
| return function (newThisType) { $thisType = newThisType; }; | |
| }); | |
| })(); | |
| /* enum IESTools.SpecificationType */ | |
| JSIL.MakeEnum( | |
| { | |
| FullName: "IESTools.SpecificationType", | |
| BaseType: $asm01.TypeRef("System.Int32"), | |
| IsPublic: true, | |
| IsFlags: false, | |
| }, | |
| { | |
| LM631986: 0, | |
| LM631991: 1, | |
| LM631995: 2, | |
| LM632002: 3, | |
| } | |
| ); | |
| /* enum IESTools.PhotometryType */ | |
| JSIL.MakeEnum( | |
| { | |
| FullName: "IESTools.PhotometryType", | |
| BaseType: $asm01.TypeRef("System.Int32"), | |
| IsPublic: true, | |
| IsFlags: false, | |
| }, | |
| { | |
| C: 1, | |
| B: 2, | |
| A: 3, | |
| } | |
| ); | |
| /* enum IESTools.Units */ | |
| JSIL.MakeEnum( | |
| { | |
| FullName: "IESTools.Units", | |
| BaseType: $asm01.TypeRef("System.Int32"), | |
| IsPublic: true, | |
| IsFlags: false, | |
| }, | |
| { | |
| Feet: 1, | |
| Meters: 2, | |
| } | |
| ); | |
| /* class IESTools.IesParser */ | |
| (function IesParser$Members () { | |
| var $, $thisType; | |
| var $T00 = function () { | |
| return ($T00 = JSIL.Memoize($asm01.System.String)) (); | |
| }; | |
| var $T01 = function () { | |
| return ($T01 = JSIL.Memoize($asm01.System.IO.StreamReader)) (); | |
| }; | |
| var $T02 = function () { | |
| return ($T02 = JSIL.Memoize($asm01.System.Int32)) (); | |
| }; | |
| var $T03 = function () { | |
| return ($T03 = JSIL.Memoize($asm01.System.Collections.Generic.List$b1.Of($asm01.System.Single))) (); | |
| }; | |
| var $T04 = function () { | |
| return ($T04 = JSIL.Memoize($asm01.System.IO.TextReader)) (); | |
| }; | |
| var $T05 = function () { | |
| return ($T05 = JSIL.Memoize(System.Array.Of($asm01.System.String))) (); | |
| }; | |
| var $T06 = function () { | |
| return ($T06 = JSIL.Memoize($asm01.System.Char)) (); | |
| }; | |
| var $T07 = function () { | |
| return ($T07 = JSIL.Memoize(System.Array.Of($asm01.System.Char))) (); | |
| }; | |
| var $T08 = function () { | |
| return ($T08 = JSIL.Memoize($asm01.System.StringSplitOptions)) (); | |
| }; | |
| var $T09 = function () { | |
| return ($T09 = JSIL.Memoize($asm01.System.Single)) (); | |
| }; | |
| var $T0A = function () { | |
| return ($T0A = JSIL.Memoize($asm00.IESTools.IesData)) (); | |
| }; | |
| var $T0B = function () { | |
| return ($T0B = JSIL.Memoize($asm01.System.IO.FileStream)) (); | |
| }; | |
| var $T0C = function () { | |
| return ($T0C = JSIL.Memoize($asm01.System.IO.FileMode)) (); | |
| }; | |
| var $T0D = function () { | |
| return ($T0D = JSIL.Memoize($asm01.System.IO.FileAccess)) (); | |
| }; | |
| var $T0E = function () { | |
| return ($T0E = JSIL.Memoize($asm00.IESTools.IesParser_Direction)) (); | |
| }; | |
| var $T0F = function () { | |
| return ($T0F = JSIL.Memoize($asm01.System.IDisposable)) (); | |
| }; | |
| var $T10 = function () { | |
| return ($T10 = JSIL.Memoize(System.Array.Of($asm00.IESTools.AngleCandela))) (); | |
| }; | |
| var $T11 = function () { | |
| return ($T11 = JSIL.Memoize($asm00.IESTools.SpecificationType)) (); | |
| }; | |
| var $T12 = function () { | |
| return ($T12 = JSIL.Memoize($asm01.System.Exception)) (); | |
| }; | |
| var $T13 = function () { | |
| return ($T13 = JSIL.Memoize($asm01.System.Collections.Generic.Dictionary$b2.Of($asm01.System.String, $asm01.System.String))) (); | |
| }; | |
| var $T14 = function () { | |
| return ($T14 = JSIL.Memoize($asm00.IESTools.AngleCandela)) (); | |
| }; | |
| var $T15 = function () { | |
| return ($T15 = JSIL.Memoize($asm00.IESTools.PhotometryType)) (); | |
| }; | |
| var $T16 = function () { | |
| return ($T16 = JSIL.Memoize($asm00.IESTools.Units)) (); | |
| }; | |
| var $S00 = function () { | |
| return ($S00 = JSIL.Memoize(new JSIL.ConstructorSignature($asm01.TypeRef("System.Collections.Generic.List`1", [$asm01.TypeRef("System.Single")]), null))) (); | |
| }; | |
| var $S01 = function () { | |
| return ($S01 = JSIL.Memoize(new JSIL.ConstructorSignature($asm01.TypeRef("System.IO.FileStream"), [ | |
| $asm01.TypeRef("System.String"), $asm01.TypeRef("System.IO.FileMode"), | |
| $asm01.TypeRef("System.IO.FileAccess") | |
| ]))) (); | |
| }; | |
| var $S02 = function () { | |
| return ($S02 = JSIL.Memoize(new JSIL.ConstructorSignature($asm01.TypeRef("System.IO.StreamReader"), [$asm01.TypeRef("System.IO.Stream")]))) (); | |
| }; | |
| var $S03 = function () { | |
| return ($S03 = JSIL.Memoize(new JSIL.MethodSignature($asm01.TypeRef("System.Single"), [$asm01.TypeRef("System.Int32")]))) (); | |
| }; | |
| var $S04 = function () { | |
| return ($S04 = JSIL.Memoize(new JSIL.ConstructorSignature($asm01.TypeRef("System.Exception"), [$asm01.TypeRef("System.String")]))) (); | |
| }; | |
| var $IM00 = function () { | |
| return ($IM00 = JSIL.Memoize($asm01.System.IDisposable.Dispose)) (); | |
| }; | |
| function IesParser__ctor (path) { | |
| this.path = path; | |
| }; | |
| function IesParser_GetFloatValues (reader, totalValues) { | |
| var allValues = $S00().Construct(); | |
| for (var count = 0; count < (totalValues | 0); ) { | |
| var line = (reader.ReadLine().trim()); | |
| var lineValues = (JSIL.SplitString(line, JSIL.Array.New($T06(), [" "]), $T08().RemoveEmptyEntries)); | |
| var array = lineValues; | |
| for (var i = 0; i < (array.length | 0); i = ((i + 1) | 0)) { | |
| var val = array[i]; | |
| allValues.Add($T09().Parse(val)); | |
| count = ((count + 1) | 0); | |
| } | |
| } | |
| return allValues; | |
| }; | |
| function IesParser_Parse () { | |
| this.ies = new ($T0A())(); | |
| var fs = $S01().Construct(this.path, $T0C().Open, $T0D().Read); | |
| try { | |
| var reader = $S02().Construct(fs); | |
| try { | |
| this.ParseIdentifier(reader); | |
| this.ParseKeywords(reader); | |
| this.ParseTilt(reader); | |
| this.ParseLampData(reader); | |
| this.ParseBallastData(reader); | |
| this.ParseAngles(reader, $T0E().Vertical); | |
| this.ParseAngles(reader, $T0E().Horizontal); | |
| this.ParseCandelas(reader); | |
| } finally { | |
| if (reader !== null) { | |
| $IM00().Call(reader, null); | |
| } | |
| } | |
| } finally { | |
| if (fs !== null) { | |
| $IM00().Call(fs, null); | |
| } | |
| } | |
| return this.ies; | |
| }; | |
| function IesParser_ParseAngles (reader, direction) { | |
| var allAngleValues = this.GetFloatValues(reader, ( | |
| ((direction.valueOf() | 0) !== 0) | |
| ? this.ies.horizontalAnglesCount | |
| : this.ies.verticalAnglesCount) | |
| ); | |
| for (var vert = 0; vert < (this.ies.verticalAnglesCount | 0); vert = ((vert + 1) | 0)) { | |
| for (var horiz = 0; horiz < (this.ies.horizontalAnglesCount | 0); horiz = ((horiz + 1) | 0)) { | |
| if (direction === $T0E().Horizontal) { | |
| (this.ies.angleCandelas).Get(vert, horiz).horizontalAngle = +$S03().CallVirtual("get_Item", null, allAngleValues, horiz); | |
| } else if ((direction.valueOf() | 0) === 0) { | |
| (this.ies.angleCandelas).Get(vert, horiz).verticalAngle = +$S03().CallVirtual("get_Item", null, allAngleValues, vert); | |
| } | |
| } | |
| } | |
| }; | |
| function IesParser_ParseBallastData (reader) { | |
| var line = (reader.ReadLine().trim()); | |
| var val = (JSIL.SplitString(line, JSIL.Array.New($T06(), [" "]))); | |
| this.ies.ballastFactor = +$T09().Parse(val[0]); | |
| this.ies.inputWatts = +$T09().Parse(val[2]); | |
| }; | |
| function IesParser_ParseCandelas (reader) { | |
| for (var y = 0; y < (this.ies.verticalAnglesCount | 0); y = ((y + 1) | 0)) { | |
| var currentCandelaValues = this.GetFloatValues(reader, this.ies.verticalAnglesCount); | |
| for (var x = 0; x < (this.ies.horizontalAnglesCount | 0); x = ((x + 1) | 0)) { | |
| (this.ies.angleCandelas).Get(y, x).candela = +$S03().CallVirtual("get_Item", null, currentCandelaValues, y); | |
| } | |
| } | |
| }; | |
| function IesParser_ParseIdentifier (reader) { | |
| var line = (reader.ReadLine().trim()); | |
| if (System.String.StartsWith(line, "IESNA")) { | |
| var $label0 = 0; | |
| $labelgroup0: | |
| while (true) { | |
| switch ($label0) { | |
| case 0: /* $entry0 */ | |
| if (line !== null) { | |
| if (!(line == "IESNA:LM-63-1991")) { | |
| if (!(line == "IESNA:LM-63-1995")) { | |
| if (!(line == "IESNA:LM-63-2002")) { | |
| $label0 = 1 /* goto IL_8C */ ; | |
| continue $labelgroup0; | |
| } | |
| this.ies.identifier = $T11().LM632002; | |
| } else { | |
| this.ies.identifier = $T11().LM631995; | |
| } | |
| } else { | |
| this.ies.identifier = $T11().LM631991; | |
| } | |
| return; | |
| } | |
| $label0 = 1 /* goto IL_8C */ ; | |
| continue $labelgroup0; | |
| case 1: /* IL_8C */ | |
| throw $S04().Construct("IES specification identifier not recognized"); | |
| break $labelgroup0; | |
| } | |
| } | |
| } | |
| this.ies.identifier = $T11().LM631986; | |
| }; | |
| function IesParser_ParseKeywords (reader) { | |
| switch ((this.ies.identifier).valueOf()) { | |
| case 2: | |
| this.ParseKeywordsGeneric(reader); | |
| break; | |
| case 3: | |
| this.ParseKeywordsGeneric(reader); | |
| break; | |
| } | |
| }; | |
| function IesParser_ParseKeywordsGeneric (reader) { | |
| var keywords = null, key2 = null; | |
| var lastKey = ""; | |
| while ((reader.Peek() | 0) === 91) { | |
| var line = (reader.ReadLine().trim()); | |
| var splitIndex = (((line.indexOf("]")) + 1) | 0); | |
| var key = (System.String.Replace(System.String.Replace(line.substr(0, splitIndex), "[", ""), "]", "")); | |
| var val = (line.substr(splitIndex).trim()); | |
| if (!$T00().IsNullOrEmpty(val)) { | |
| if (!(!(key == "MORE") || $T00().IsNullOrEmpty(lastKey))) { | |
| (keywords = this.ies.keywords).set_Item(key2 = lastKey, (keywords.get_Item(key2) + "\n" + val)); | |
| } else { | |
| (this.ies.keywords).Add(key, val); | |
| lastKey = key; | |
| } | |
| } | |
| } | |
| }; | |
| function IesParser_ParseLampData (reader) { | |
| var line = (reader.ReadLine().trim()); | |
| var data = (JSIL.SplitString(line, JSIL.Array.New($T06(), [" "]))); | |
| this.ies.lampCount = ($T02().Parse(data[0]) | 0); | |
| this.ies.lumensPerLamp = +$T09().Parse(data[1]); | |
| this.ies.candelaMultiplier = +$T09().Parse(data[2]); | |
| this.ies.verticalAnglesCount = ($T02().Parse(data[3]) | 0); | |
| this.ies.horizontalAnglesCount = ($T02().Parse(data[4]) | 0); | |
| this.ies.angleCandelas = JSIL.MultidimensionalArray.New($T14(), this.ies.verticalAnglesCount, this.ies.horizontalAnglesCount); | |
| this.ies.photometryType = $T15().$Cast($T02().Parse(data[5])); | |
| this.ies.units = $T16().$Cast($T02().Parse(data[6])); | |
| this.ies.sizeX = +$T09().Parse(data[7]); | |
| this.ies.sizeY = +$T09().Parse(data[8]); | |
| this.ies.sizeZ = +$T09().Parse(data[9]); | |
| }; | |
| function IesParser_ParseTilt (reader) { | |
| var line = (reader.ReadLine().trim()); | |
| var tilt = (JSIL.SplitString(line, JSIL.Array.New($T06(), ["="]))[1].trim()); | |
| if (tilt !== null) { | |
| if (tilt == "NONE") { | |
| return; | |
| } | |
| if (tilt == "INHERIT") { | |
| throw $S04().Construct("Can't use TILT type of INHERIT"); | |
| } | |
| } | |
| reader.ReadLine(); | |
| throw $S04().Construct("Can't use TILT type"); | |
| }; | |
| JSIL.MakeType({ | |
| BaseType: $asm01.TypeRef("System.Object"), | |
| Name: "IESTools.IesParser", | |
| IsPublic: true, | |
| IsReferenceType: true, | |
| MaximumConstructorArguments: 1, | |
| }, function ($interfaceBuilder) { | |
| $ = $interfaceBuilder; | |
| $.Method({Static:false, Public:true }, ".ctor", | |
| JSIL.MethodSignature.Action($.String), | |
| IesParser__ctor | |
| ); | |
| $.Method({Static:false, Public:false}, "GetFloatValues", | |
| new JSIL.MethodSignature($asm01.TypeRef("System.Collections.Generic.List`1", [$.Single]), [$asm01.TypeRef("System.IO.StreamReader"), $.Int32]), | |
| IesParser_GetFloatValues | |
| ); | |
| $.Method({Static:false, Public:true }, "Parse", | |
| JSIL.MethodSignature.Return($asm00.TypeRef("IESTools.IesData")), | |
| IesParser_Parse | |
| ); | |
| $.Method({Static:false, Public:false}, "ParseAngles", | |
| new JSIL.MethodSignature(null, [$asm01.TypeRef("System.IO.StreamReader"), $asm00.TypeRef("IESTools.IesParser+Direction")]), | |
| IesParser_ParseAngles | |
| ); | |
| $.Method({Static:false, Public:false}, "ParseBallastData", | |
| JSIL.MethodSignature.Action($asm01.TypeRef("System.IO.StreamReader")), | |
| IesParser_ParseBallastData | |
| ); | |
| $.Method({Static:false, Public:false}, "ParseCandelas", | |
| JSIL.MethodSignature.Action($asm01.TypeRef("System.IO.StreamReader")), | |
| IesParser_ParseCandelas | |
| ); | |
| $.Method({Static:false, Public:false}, "ParseIdentifier", | |
| JSIL.MethodSignature.Action($asm01.TypeRef("System.IO.StreamReader")), | |
| IesParser_ParseIdentifier | |
| ); | |
| $.Method({Static:false, Public:false}, "ParseKeywords", | |
| JSIL.MethodSignature.Action($asm01.TypeRef("System.IO.StreamReader")), | |
| IesParser_ParseKeywords | |
| ); | |
| $.Method({Static:false, Public:false}, "ParseKeywordsGeneric", | |
| JSIL.MethodSignature.Action($asm01.TypeRef("System.IO.StreamReader")), | |
| IesParser_ParseKeywordsGeneric | |
| ); | |
| $.Method({Static:false, Public:false}, "ParseLampData", | |
| JSIL.MethodSignature.Action($asm01.TypeRef("System.IO.StreamReader")), | |
| IesParser_ParseLampData | |
| ); | |
| $.Method({Static:false, Public:false}, "ParseTilt", | |
| JSIL.MethodSignature.Action($asm01.TypeRef("System.IO.StreamReader")), | |
| IesParser_ParseTilt | |
| ); | |
| $.Field({Static:false, Public:false}, "path", $.String); | |
| $.Field({Static:false, Public:false}, "ies", $asm00.TypeRef("IESTools.IesData")); | |
| return function (newThisType) { $thisType = newThisType; }; | |
| }); | |
| })(); | |
| /* enum IESTools.IesParser+Direction */ | |
| JSIL.MakeEnum( | |
| { | |
| FullName: "IESTools.IesParser+Direction", | |
| BaseType: $asm01.TypeRef("System.Int32"), | |
| IsPublic: false, | |
| IsFlags: false, | |
| }, | |
| { | |
| Vertical: 0, | |
| Horizontal: 1, | |
| } | |
| ); | |
| /* class IESTools.IesData */ | |
| (function IesData$Members () { | |
| var $, $thisType; | |
| var $T00 = function () { | |
| return ($T00 = JSIL.Memoize($asm01.System.Collections.Generic.Dictionary$b2.Of($asm01.System.String, $asm01.System.String))) (); | |
| }; | |
| var $S00 = function () { | |
| return ($S00 = JSIL.Memoize(new JSIL.ConstructorSignature($asm01.TypeRef("System.Collections.Generic.Dictionary`2", [$asm01.TypeRef("System.String"), $asm01.TypeRef("System.String")]), null))) (); | |
| }; | |
| function IesData__ctor () { | |
| this.keywords = $S00().Construct(); | |
| }; | |
| JSIL.MakeType({ | |
| BaseType: $asm01.TypeRef("System.Object"), | |
| Name: "IESTools.IesData", | |
| IsPublic: true, | |
| IsReferenceType: true, | |
| MaximumConstructorArguments: 0, | |
| }, function ($interfaceBuilder) { | |
| $ = $interfaceBuilder; | |
| $.Method({Static:false, Public:true }, ".ctor", | |
| JSIL.MethodSignature.Void, | |
| IesData__ctor | |
| ); | |
| $.Field({Static:false, Public:true }, "identifier", $asm00.TypeRef("IESTools.SpecificationType")); | |
| $.Field({Static:false, Public:true }, "keywords", $asm01.TypeRef("System.Collections.Generic.Dictionary`2", [$.String, $.String])); | |
| $.Field({Static:false, Public:true }, "lampCount", $.Int32); | |
| $.Field({Static:false, Public:true }, "lumensPerLamp", $.Single); | |
| $.Field({Static:false, Public:true }, "candelaMultiplier", $.Single); | |
| $.Field({Static:false, Public:true }, "verticalAnglesCount", $.Int32); | |
| $.Field({Static:false, Public:true }, "horizontalAnglesCount", $.Int32); | |
| $.Field({Static:false, Public:true }, "photometryType", $asm00.TypeRef("IESTools.PhotometryType")); | |
| $.Field({Static:false, Public:true }, "units", $asm00.TypeRef("IESTools.Units")); | |
| $.Field({Static:false, Public:true }, "sizeX", $.Single); | |
| $.Field({Static:false, Public:true }, "sizeY", $.Single); | |
| $.Field({Static:false, Public:true }, "sizeZ", $.Single); | |
| $.Field({Static:false, Public:true }, "ballastFactor", $.Single); | |
| $.Field({Static:false, Public:true }, "inputWatts", $.Single); | |
| $.Field({Static:false, Public:true }, "angleCandelas", $jsilcore.TypeRef("System.Array", [$asm00.TypeRef("IESTools.AngleCandela")])); | |
| return function (newThisType) { $thisType = newThisType; }; | |
| }); | |
| })(); | |
| /* class IESTools.IesCubemap */ | |
| (function IesCubemap$Members () { | |
| var $, $thisType; | |
| var $T00 = function () { | |
| return ($T00 = JSIL.Memoize($asm01.System.Int32)) (); | |
| }; | |
| var $T01 = function () { | |
| return ($T01 = JSIL.Memoize($asm01.System.Collections.Generic.Dictionary$b2.Of($asm00.IESTools.CubeFace, $asm00.IESTools.IesTexture))) (); | |
| }; | |
| var $T02 = function () { | |
| return ($T02 = JSIL.Memoize($asm00.IESTools.CubeFace)) (); | |
| }; | |
| var $T03 = function () { | |
| return ($T03 = JSIL.Memoize($asm00.IESTools.IesTexture)) (); | |
| }; | |
| var $T04 = function () { | |
| return ($T04 = JSIL.Memoize($asm01.System.Double)) (); | |
| }; | |
| var $T05 = function () { | |
| return ($T05 = JSIL.Memoize($asm00.IESTools.Vec3)) (); | |
| }; | |
| var $T06 = function () { | |
| return ($T06 = JSIL.Memoize($asm01.System.Math)) (); | |
| }; | |
| var $S00 = function () { | |
| return ($S00 = JSIL.Memoize(new JSIL.ConstructorSignature($asm01.TypeRef("System.Collections.Generic.Dictionary`2", [$asm00.TypeRef("IESTools.CubeFace"), $asm00.TypeRef("IESTools.IesTexture")]), null))) (); | |
| }; | |
| var $S01 = function () { | |
| return ($S01 = JSIL.Memoize(new JSIL.MethodSignature($asm00.TypeRef("IESTools.Vec3"), [ | |
| $asm01.TypeRef("System.Double"), $asm01.TypeRef("System.Double"), | |
| $asm01.TypeRef("System.Double") | |
| ]))) (); | |
| }; | |
| function IesCubemap__ctor (resolution) { | |
| this.resolution = (resolution | 0); | |
| this.textures = $S00().Construct(); | |
| (this.textures).Add($T02().Right, new ($T03())(resolution, resolution)); | |
| (this.textures).Add($T02().Left, new ($T03())(resolution, resolution)); | |
| (this.textures).Add($T02().Top, new ($T03())(resolution, resolution)); | |
| (this.textures).Add($T02().Bottom, new ($T03())(resolution, resolution)); | |
| (this.textures).Add($T02().Front, new ($T03())(resolution, resolution)); | |
| (this.textures).Add($T02().Back, new ($T03())(resolution, resolution)); | |
| }; | |
| function IesCubemap_CubeToSpherePoint$00 (face, x, y) { | |
| switch (face.valueOf()) { | |
| case 0: | |
| var result = $S01().CallStatic($thisType, "CubeToSpherePoint", null, 0.5, y, -x).MemberwiseClone(); | |
| break; | |
| case 1: | |
| result = $S01().CallStatic($thisType, "CubeToSpherePoint", null, -0.5, y, x).MemberwiseClone(); | |
| break; | |
| case 2: | |
| result = $S01().CallStatic($thisType, "CubeToSpherePoint", null, x, 0.5, y).MemberwiseClone(); | |
| break; | |
| case 3: | |
| result = $S01().CallStatic($thisType, "CubeToSpherePoint", null, x, -0.5, -y).MemberwiseClone(); | |
| break; | |
| case 4: | |
| result = $S01().CallStatic($thisType, "CubeToSpherePoint", null, x, y, -0.5).MemberwiseClone(); | |
| break; | |
| case 5: | |
| result = $S01().CallStatic($thisType, "CubeToSpherePoint", null, -x, y, 0.5).MemberwiseClone(); | |
| break; | |
| default: | |
| result = new ($T05())(0, 0, 0); | |
| break; | |
| } | |
| return result; | |
| }; | |
| function IesCubemap_CubeToSpherePoint$01 (x, y, z) { | |
| var point = new ($T05())(); | |
| point.x = +x * (Math.sqrt((((1 - +(((+y * +y) / 2))) - +(((+z * +z) / 2))) + +(((((+y * +y) * +z) * +z) / 3))))); | |
| point.y = +y * (Math.sqrt((((1 - +(((+z * +z) / 2))) - +(((+x * +x) / 2))) + +(((((+z * +z) * +x) * +x) / 3))))); | |
| point.z = +z * (Math.sqrt((((1 - +(((+x * +x) / 2))) - +(((+y * +y) / 2))) + +(((((+x * +x) * +y) * +y) / 3))))); | |
| return point; | |
| }; | |
| JSIL.MakeType({ | |
| BaseType: $asm01.TypeRef("System.Object"), | |
| Name: "IESTools.IesCubemap", | |
| IsPublic: true, | |
| IsReferenceType: true, | |
| MaximumConstructorArguments: 1, | |
| }, function ($interfaceBuilder) { | |
| $ = $interfaceBuilder; | |
| $.Method({Static:false, Public:true }, ".ctor", | |
| JSIL.MethodSignature.Action($.Int32), | |
| IesCubemap__ctor | |
| ); | |
| $.Method({Static:true , Public:true }, "CubeToSpherePoint", | |
| new JSIL.MethodSignature($asm00.TypeRef("IESTools.Vec3"), [ | |
| $asm00.TypeRef("IESTools.CubeFace"), $.Double, | |
| $.Double | |
| ]), | |
| IesCubemap_CubeToSpherePoint$00 | |
| ); | |
| $.Method({Static:true , Public:true }, "CubeToSpherePoint", | |
| new JSIL.MethodSignature($asm00.TypeRef("IESTools.Vec3"), [ | |
| $.Double, $.Double, | |
| $.Double | |
| ]), | |
| IesCubemap_CubeToSpherePoint$01 | |
| ); | |
| $.Field({Static:false, Public:true , ReadOnly:true }, "resolution", $.Int32); | |
| $.Field({Static:false, Public:true , ReadOnly:true }, "textures", $asm01.TypeRef("System.Collections.Generic.Dictionary`2", [$asm00.TypeRef("IESTools.CubeFace"), $asm00.TypeRef("IESTools.IesTexture")])); | |
| return function (newThisType) { $thisType = newThisType; }; | |
| }); | |
| })(); | |
| /* struct IESTools.AngleCandela */ | |
| (function AngleCandela$Members () { | |
| var $, $thisType; | |
| JSIL.MakeType({ | |
| BaseType: $asm01.TypeRef("System.ValueType"), | |
| Name: "IESTools.AngleCandela", | |
| IsPublic: true, | |
| IsReferenceType: false, | |
| MaximumConstructorArguments: 0, | |
| SequentialLayout: true, | |
| }, function ($interfaceBuilder) { | |
| $ = $interfaceBuilder; | |
| $.Field({Static:false, Public:true }, "horizontalAngle", $.Single); | |
| $.Field({Static:false, Public:true }, "verticalAngle", $.Single); | |
| $.Field({Static:false, Public:true }, "candela", $.Single); | |
| return function (newThisType) { $thisType = newThisType; }; | |
| }); | |
| })(); | |
| /* struct IESTools.LatLon */ | |
| (function LatLon$Members () { | |
| var $, $thisType; | |
| var $T00 = function () { | |
| return ($T00 = JSIL.Memoize($asm01.System.Double)) (); | |
| }; | |
| var $T01 = function () { | |
| return ($T01 = JSIL.Memoize($asm00.IESTools.Vec3)) (); | |
| }; | |
| var $T02 = function () { | |
| return ($T02 = JSIL.Memoize($asm01.System.Single)) (); | |
| }; | |
| var $T03 = function () { | |
| return ($T03 = JSIL.Memoize($asm01.System.Math)) (); | |
| }; | |
| function LatLon__ctor (latitude, longitude) { | |
| this.latitude = +latitude; | |
| this.longitude = +longitude; | |
| }; | |
| function LatLon_FromSpherePoint (point, radius) { | |
| var lat = (Math.acos(+((+point.y / +radius)))); | |
| var lon = (Math.atan(+((+point.x / +point.z)))); | |
| return new $thisType(lat, lon); | |
| }; | |
| JSIL.MakeType({ | |
| BaseType: $asm01.TypeRef("System.ValueType"), | |
| Name: "IESTools.LatLon", | |
| IsPublic: true, | |
| IsReferenceType: false, | |
| MaximumConstructorArguments: 2, | |
| SequentialLayout: true, | |
| }, function ($interfaceBuilder) { | |
| $ = $interfaceBuilder; | |
| $.Method({Static:false, Public:true }, ".ctor", | |
| new JSIL.MethodSignature(null, [$.Double, $.Double]), | |
| LatLon__ctor | |
| ); | |
| $.Method({Static:true , Public:true }, "FromSpherePoint", | |
| new JSIL.MethodSignature($.Type, [$asm00.TypeRef("IESTools.Vec3"), $.Single]), | |
| LatLon_FromSpherePoint | |
| ); | |
| $.Field({Static:false, Public:true , ReadOnly:true }, "latitude", $.Double); | |
| $.Field({Static:false, Public:true , ReadOnly:true }, "longitude", $.Double); | |
| return function (newThisType) { $thisType = newThisType; }; | |
| }); | |
| })(); | |
| /* enum IESTools.CubeFace */ | |
| JSIL.MakeEnum( | |
| { | |
| FullName: "IESTools.CubeFace", | |
| BaseType: $asm01.TypeRef("System.Int32"), | |
| IsPublic: true, | |
| IsFlags: false, | |
| }, | |
| { | |
| Right: 0, | |
| Left: 1, | |
| Top: 2, | |
| Bottom: 3, | |
| Front: 4, | |
| Back: 5, | |
| } | |
| ); | |
| /* struct IESTools.Vec3 */ | |
| (function Vec3$Members () { | |
| var $, $thisType; | |
| var $T00 = function () { | |
| return ($T00 = JSIL.Memoize($asm01.System.Double)) (); | |
| }; | |
| function Vec3__ctor (x, y, z) { | |
| this.x = +x; | |
| this.y = +y; | |
| this.z = +z; | |
| }; | |
| JSIL.MakeType({ | |
| BaseType: $asm01.TypeRef("System.ValueType"), | |
| Name: "IESTools.Vec3", | |
| IsPublic: true, | |
| IsReferenceType: false, | |
| MaximumConstructorArguments: 3, | |
| SequentialLayout: true, | |
| }, function ($interfaceBuilder) { | |
| $ = $interfaceBuilder; | |
| $.Method({Static:false, Public:true }, ".ctor", | |
| new JSIL.MethodSignature(null, [ | |
| $.Double, $.Double, | |
| $.Double | |
| ]), | |
| Vec3__ctor | |
| ); | |
| $.Field({Static:false, Public:true }, "x", $.Double); | |
| $.Field({Static:false, Public:true }, "y", $.Double); | |
| $.Field({Static:false, Public:true }, "z", $.Double); | |
| return function (newThisType) { $thisType = newThisType; }; | |
| }); | |
| })(); | |
| /* class IESTools.MainClass */ | |
| (function MainClass$Members () { | |
| var $, $thisType; | |
| var $T00 = function () { | |
| return ($T00 = JSIL.Memoize($asm00.IESTools.IesData)) (); | |
| }; | |
| var $T01 = function () { | |
| return ($T01 = JSIL.Memoize($asm01.System.Console)) (); | |
| }; | |
| var $T02 = function () { | |
| return ($T02 = JSIL.Memoize($asm01.System.String)) (); | |
| }; | |
| var $T03 = function () { | |
| return ($T03 = JSIL.Memoize($asm00.IESTools.SpecificationType)) (); | |
| }; | |
| var $T04 = function () { | |
| return ($T04 = JSIL.Memoize($asm01.System.Collections.Generic.Dictionary$b2_Enumerator.Of($asm01.System.String, $asm01.System.String))) (); | |
| }; | |
| var $T05 = function () { | |
| return ($T05 = JSIL.Memoize($asm01.System.Collections.Generic.Dictionary$b2.Of($asm01.System.String, $asm01.System.String))) (); | |
| }; | |
| var $T06 = function () { | |
| return ($T06 = JSIL.Memoize($asm01.System.Collections.Generic.KeyValuePair$b2.Of($asm01.System.String, $asm01.System.String))) (); | |
| }; | |
| var $T07 = function () { | |
| return ($T07 = JSIL.Memoize($asm01.System.Int32)) (); | |
| }; | |
| var $T08 = function () { | |
| return ($T08 = JSIL.Memoize($asm01.System.Single)) (); | |
| }; | |
| var $T09 = function () { | |
| return ($T09 = JSIL.Memoize($asm00.IESTools.PhotometryType)) (); | |
| }; | |
| var $T0A = function () { | |
| return ($T0A = JSIL.Memoize($asm00.IESTools.Units)) (); | |
| }; | |
| var $T0B = function () { | |
| return ($T0B = JSIL.Memoize($asm01.System.Object)) (); | |
| }; | |
| var $T0C = function () { | |
| return ($T0C = JSIL.Memoize(System.Array.Of($asm01.System.Object))) (); | |
| }; | |
| var $T0D = function () { | |
| return ($T0D = JSIL.Memoize(System.Array.Of($asm00.IESTools.AngleCandela))) (); | |
| }; | |
| var $T0E = function () { | |
| return ($T0E = JSIL.Memoize(System.Array.Of($asm01.System.String))) (); | |
| }; | |
| var $T0F = function () { | |
| return ($T0F = JSIL.Memoize($asm01.System.IO.File)) (); | |
| }; | |
| var $T10 = function () { | |
| return ($T10 = JSIL.Memoize($asm00.IESTools.IesParser)) (); | |
| }; | |
| function MainClass__ctor () { | |
| }; | |
| function MainClass_DisplayIesData (ies) { | |
| $T01().WriteLine(""); | |
| $T01().WriteLine(JSIL.ConcatString("Identifier: ", ies.identifier)); | |
| $T01().WriteLine("Keywords: "); | |
| $T01().WriteLine(); | |
| var enumerator = $T05().prototype.GetEnumerator.call(ies.keywords); | |
| while ($T04().prototype.MoveNext.call(enumerator)) { | |
| var keyword = $T04().prototype.get_Current.call(enumerator); | |
| $T01().WriteLine($T02().Format( | |
| " {0,-12} {1}", | |
| keyword.get_Key(), | |
| keyword.get_Value() | |
| )); | |
| } | |
| $T01().WriteLine(); | |
| $T01().WriteLine(JSIL.ConcatString("Lamp Count: ", ies.lampCount)); | |
| $T01().WriteLine(JSIL.ConcatString("Lumens: ", ies.lumensPerLamp)); | |
| $T01().WriteLine(JSIL.ConcatString("Multiplier: ", ies.candelaMultiplier)); | |
| $T01().WriteLine(JSIL.ConcatString("Vertical Angles: ", ies.verticalAnglesCount)); | |
| $T01().WriteLine(JSIL.ConcatString("Horizontal Angles: ", ies.horizontalAnglesCount)); | |
| $T01().WriteLine(JSIL.ConcatString("Photometry Type: ", ies.photometryType)); | |
| $T01().WriteLine(JSIL.ConcatString("Units: ", ies.units)); | |
| $T01().WriteLine(JSIL.ConcatString.apply(null, JSIL.Array.New($T0B(), ["Size: ", ies.sizeX, ", ", ies.sizeY, ", ", ies.sizeZ]))); | |
| $T01().WriteLine(JSIL.ConcatString("BallastFactor: ", ies.ballastFactor)); | |
| $T01().WriteLine(JSIL.ConcatString("InputWatts: ", ies.inputWatts)); | |
| $T01().WriteLine(); | |
| $T01().WriteLine("Candela Values:"); | |
| $T01().WriteLine(); | |
| for (var i = 0; i < (ies.horizontalAnglesCount | 0); i = ((i + 1) | 0)) { | |
| for (var j = 0; j < (ies.verticalAnglesCount | 0); j = ((j + 1) | 0)) { | |
| $T01().Write($T02().Format("{0,5} | ", (ies.angleCandelas).Get(i, j).candela)); | |
| } | |
| $T01().WriteLine(); | |
| } | |
| $T01().WriteLine(); | |
| }; | |
| function MainClass_Main (args) { | |
| if ((args.length | 0) === 1) { | |
| if ($T0F().Exists(args[0])) { | |
| var parser = new ($T10())(args[0]); | |
| var ies = parser.Parse(); | |
| $thisType.DisplayIesData(ies); | |
| } else { | |
| $T01().WriteLine(); | |
| $T01().WriteLine("Not a valid IES file"); | |
| $T01().WriteLine(); | |
| } | |
| } else { | |
| $T01().WriteLine("Please specify a path to an IES file"); | |
| } | |
| }; | |
| JSIL.MakeType({ | |
| BaseType: $asm01.TypeRef("System.Object"), | |
| Name: "IESTools.MainClass", | |
| IsPublic: false, | |
| IsReferenceType: true, | |
| MaximumConstructorArguments: 0, | |
| }, function ($interfaceBuilder) { | |
| $ = $interfaceBuilder; | |
| $.Method({Static:false, Public:true }, ".ctor", | |
| JSIL.MethodSignature.Void, | |
| MainClass__ctor | |
| ); | |
| $.Method({Static:true , Public:false}, "DisplayIesData", | |
| JSIL.MethodSignature.Action($asm00.TypeRef("IESTools.IesData")), | |
| MainClass_DisplayIesData | |
| ); | |
| $.Method({Static:true , Public:true }, "Main", | |
| JSIL.MethodSignature.Action($jsilcore.TypeRef("System.Array", [$.String])), | |
| MainClass_Main | |
| ); | |
| return function (newThisType) { $thisType = newThisType; }; | |
| }); | |
| })(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Reflection; | |
| using System.Runtime.CompilerServices; | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| using System.IO; | |
| namespace IESTools | |
| { | |
| /// <summary> | |
| /// A pixel in RGBE format. | |
| /// </summary> | |
| public struct RGBEPixel | |
| { | |
| public byte r; | |
| public byte g; | |
| public byte b; | |
| public byte e; | |
| public RGBEPixel (float r, float g, float b) | |
| { | |
| // Based on code by Greg Ward and Bruce Walter | |
| // http://www.graphics.cornell.edu/%7Ebjw/rgbe/rgbe.c | |
| float val = r; | |
| if (g > val) | |
| val = g; | |
| if (b > val) | |
| val = b; | |
| if (val < 1e-32) { | |
| this.r = this.g = this.b = this.e = 0; | |
| } else { | |
| int exponent; | |
| val = Frexp (val, out exponent) * 256f / val; | |
| this.r = (byte)(r * val); | |
| this.g = (byte)(g * val); | |
| this.b = (byte)(b * val); | |
| this.e = (byte)(exponent + 128); | |
| } | |
| } | |
| /// <summary> | |
| /// Extract the mantissa and exponent from a value | |
| /// </summary> | |
| static float Frexp (float value, out int exponent) | |
| { | |
| // FIXME | |
| exponent = 1; | |
| return 1; | |
| // // http://stackoverflow.com/questions/389993/extracting-mantissa-and-exponent-from-double-in-c-sharp/390072#390072 | |
| // long bits = BitConverter.DoubleToInt64Bits (value); | |
| // bool negative = (bits < 0); | |
| // exponent = (int) ((bits >> 52) & 0x7ffL); | |
| // long mantissa = bits & 0xfffffffffffffL; | |
| // if (exponent==0) { | |
| // exponent++; | |
| // } else { | |
| // mantissa = mantissa | (1L<<52); | |
| // } | |
| // exponent -= 1075; | |
| // if (mantissa == 0) { | |
| // return 0; | |
| // } | |
| // while ((mantissa & 1) == 0) | |
| // { | |
| // mantissa >>= 1; | |
| // exponent++; | |
| // } | |
| // return mantissa; | |
| } | |
| public override bool Equals (System.Object obj) | |
| { | |
| if (obj == null) { | |
| return false; | |
| } | |
| if (obj is RGBEPixel == false) { | |
| return false; | |
| } | |
| var p = (RGBEPixel)obj; | |
| return (p.r == r && p.g == g && p.b == b && p.e == e); | |
| } | |
| public static bool operator ==(RGBEPixel a, RGBEPixel b) | |
| { | |
| if (System.Object.ReferenceEquals (a, b)) { | |
| return true; | |
| } | |
| if ((object)a == null || (object)b == null) { | |
| return false; | |
| } | |
| return (a.r == b.r && a.g == b.g && a.b == b.b && a.e == b.e); | |
| } | |
| public static bool operator !=(RGBEPixel a, RGBEPixel b) | |
| { | |
| return !(a == b); | |
| } | |
| public override int GetHashCode () | |
| { | |
| return r ^ g ^ b ^ e; | |
| } | |
| } | |
| /// <summary> | |
| /// An RGBE image file, originally developed for the Radiance renderer. | |
| /// Specification: http://paulbourke.net/dataformats/pic/ | |
| /// </summary> | |
| public class RGBEFile | |
| { | |
| public string creatorName; | |
| IesTexture texture; | |
| public RGBEFile (IesTexture texture) | |
| { | |
| this.texture = texture; | |
| } | |
| public byte[] GetBytes () | |
| { | |
| var sb = new System.Text.StringBuilder (); | |
| sb.AppendLine ("#?RADIANCE"); | |
| if (!string.IsNullOrEmpty (creatorName)) { | |
| sb.AppendLine ("# Made with " + creatorName); | |
| } | |
| sb.AppendLine ("FORMAT=32-bit_rle_rgbe"); | |
| sb.AppendFormat ("-Y {0} +X {1}", texture.Width, texture.Height); | |
| sb.AppendLine (); | |
| char[] data = new char[sb.Length]; | |
| sb.CopyTo (0, data, 0, sb.Length); | |
| for (int y = 0; y < texture.Height; y++) { | |
| for (int x = 0; x < texture.Width; x++) { | |
| // RLE | |
| if (x > 0 && texture.ReadPixelIntensity (x - 1, y) == texture.ReadPixelIntensity (x, y)) { | |
| // TODO write RLE data | |
| // http://www.graphics.cornell.edu/%7Ebjw/rgbe/rgbe.c | |
| } else { | |
| // TODO write the pixel value | |
| } | |
| } | |
| } | |
| // TODO | |
| return new byte[0]; | |
| } | |
| } | |
| public class IesTexture | |
| { | |
| public int Width { get; private set; } | |
| public int Height { get; private set; } | |
| double[,] intensities; | |
| public IesTexture (int width, int height) | |
| { | |
| this.Width = width; | |
| this.Height = height; | |
| intensities = new double[width, height]; | |
| } | |
| public void WritePixelIntensity (int x, int y, double intensity) | |
| { | |
| intensities [x, y] = intensity; | |
| } | |
| public double ReadPixelIntensity (int x, int y) | |
| { | |
| return intensities [x, y]; | |
| } | |
| } | |
| public class IesRenderer | |
| { | |
| public IesRenderer () | |
| { | |
| } | |
| 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; | |
| } | |
| double InterpolatedCandelaFromData (LatLon position, AngleCandela[,] data) | |
| { | |
| // TODO interpolation function | |
| return 0; | |
| } | |
| } | |
| public enum SpecificationType | |
| { | |
| LM631986, | |
| LM631991, | |
| LM631995, | |
| LM632002 | |
| } | |
| public enum PhotometryType | |
| { | |
| C = 1, | |
| B = 2, | |
| A = 3 | |
| } | |
| public enum Units | |
| { | |
| Feet = 1, | |
| Meters = 2 | |
| } | |
| public class IesParser | |
| { | |
| enum Direction { | |
| Vertical, | |
| Horizontal | |
| } | |
| string path; | |
| IesData ies; | |
| public IesParser (string path) | |
| { | |
| this.path = path; | |
| } | |
| 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; | |
| } | |
| void ParseIdentifier (StreamReader reader) | |
| { | |
| var line = reader.ReadLine ().Trim (); | |
| if (line.StartsWith ("IESNA")) { | |
| switch (line) { | |
| case "IESNA:LM-63-1991": | |
| ies.identifier = SpecificationType.LM631991; | |
| break; | |
| case "IESNA:LM-63-1995": | |
| ies.identifier = SpecificationType.LM631995; | |
| break; | |
| case "IESNA:LM-63-2002": | |
| // FIXME unable to find documentation on this format | |
| ies.identifier = SpecificationType.LM632002; | |
| break; | |
| default: | |
| throw new System.Exception ("IES specification identifier not recognized"); | |
| } | |
| } else { | |
| // we have to assume it's LM-63-1986 format since this format contains no identifier | |
| ies.identifier = SpecificationType.LM631986; | |
| } | |
| } | |
| void ParseKeywords (StreamReader reader) | |
| { | |
| switch (ies.identifier) { | |
| case SpecificationType.LM631986: | |
| // The 1986 specification does not contains user-defined keywords, rather the | |
| // file begins with comments requiring an arbitrary number of lines. | |
| // FIXME add file type | |
| break; | |
| case SpecificationType.LM631991: | |
| // FIXME add file type | |
| break; | |
| case SpecificationType.LM631995: | |
| ParseKeywordsGeneric (reader); | |
| break; | |
| case SpecificationType.LM632002: | |
| ParseKeywordsGeneric (reader); | |
| break; | |
| } | |
| } | |
| void ParseKeywordsGeneric (StreamReader reader) | |
| { | |
| string lastKey = ""; | |
| while (reader.Peek () == '[') { | |
| var line = reader.ReadLine ().Trim (); | |
| int splitIndex = line.IndexOf (']') + 1; | |
| string key = line.Remove (splitIndex).Replace ("[", "").Replace ("]", ""); | |
| string val = line.Substring (splitIndex).Trim (); | |
| if (!string.IsNullOrEmpty (val)) { | |
| if (key == "MORE" && !string.IsNullOrEmpty (lastKey)) { | |
| ies.keywords[lastKey] += "\n" + val; | |
| } else { | |
| ies.keywords.Add (key, val); | |
| lastKey = key; | |
| } | |
| } | |
| } | |
| } | |
| void ParseTilt (StreamReader reader) | |
| { | |
| var line = reader.ReadLine ().Trim (); | |
| // Remove "Tilt" from the name | |
| string tilt = line.Split ('=')[1].Trim (); | |
| switch (tilt) { | |
| case "NONE": | |
| return; | |
| case "INHERIT": | |
| throw new System.Exception ("Can't use TILT type of INHERIT"); | |
| default: | |
| // FIXME The next line contains data about the tilt, but we can't use it yet | |
| reader.ReadLine (); | |
| throw new System.Exception ("Can't use TILT type"); | |
| } | |
| } | |
| void ParseLampData (StreamReader reader) | |
| { | |
| var line = reader.ReadLine ().Trim (); | |
| string[] data = line.Split (' '); | |
| ies.lampCount = int.Parse (data[0]); | |
| ies.lumensPerLamp = float.Parse (data[1]); | |
| ies.candelaMultiplier = float.Parse (data[2]); | |
| ies.verticalAnglesCount = int.Parse (data[3]); | |
| ies.horizontalAnglesCount = int.Parse (data[4]); | |
| ies.angleCandelas = new AngleCandela[ies.verticalAnglesCount, ies.horizontalAnglesCount]; | |
| ies.photometryType = (PhotometryType)(int.Parse (data[5])); | |
| ies.units = (Units)(int.Parse (data[6])); | |
| ies.sizeX = float.Parse (data [7]); | |
| ies.sizeY = float.Parse (data [8]); | |
| ies.sizeZ = float.Parse (data [9]); | |
| } | |
| void ParseBallastData (StreamReader reader) | |
| { | |
| var line = reader.ReadLine ().Trim (); | |
| string[] val = line.Split (' '); | |
| ies.ballastFactor = float.Parse (val[0]); | |
| // note: data[1] isn't used, it's reserved for future use | |
| // FIXME data[1] used to be used for "BallastLampPhotometricFactor" in older formats | |
| ies.inputWatts = float.Parse (val[2]); | |
| } | |
| void ParseAngles (StreamReader reader, Direction direction) | |
| { | |
| List<float> allAngleValues = GetFloatValues (reader, (direction == Direction.Vertical) ? ies.verticalAnglesCount : ies.horizontalAnglesCount); | |
| for (int vert = 0; vert < ies.verticalAnglesCount; vert++) { | |
| for (int horiz = 0; horiz < ies.horizontalAnglesCount; horiz++) { | |
| if (direction == Direction.Horizontal) { | |
| ies.angleCandelas[vert, horiz].horizontalAngle = allAngleValues[horiz]; | |
| } else if (direction == Direction.Vertical) { | |
| ies.angleCandelas[vert, horiz].verticalAngle = allAngleValues[vert]; | |
| } | |
| } | |
| } | |
| } | |
| void ParseCandelas (StreamReader reader) | |
| { | |
| for (int y = 0; y < ies.verticalAnglesCount; y++) { | |
| List<float> currentCandelaValues = GetFloatValues (reader, ies.verticalAnglesCount); | |
| for (int x = 0; x < ies.horizontalAnglesCount; x++) { | |
| ies.angleCandelas [y, x].candela = currentCandelaValues [y]; | |
| } | |
| } | |
| } | |
| List<float> GetFloatValues (StreamReader reader, int totalValues) | |
| { | |
| List<float> allValues = new List<float> (); | |
| int count = 0; | |
| while (count < totalValues) { | |
| string line = reader.ReadLine ().Trim (); | |
| string[] lineValues = line.Split (new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); | |
| foreach (string val in lineValues) { | |
| allValues.Add (float.Parse (val)); | |
| count++; | |
| } | |
| } | |
| return allValues; | |
| } | |
| } | |
| public class IesData | |
| { | |
| public SpecificationType identifier; | |
| public Dictionary<string, string> keywords; | |
| public int lampCount; | |
| public float lumensPerLamp; | |
| public float candelaMultiplier; | |
| public int verticalAnglesCount; | |
| public int horizontalAnglesCount; | |
| public PhotometryType photometryType; | |
| public Units units; | |
| public float sizeX; | |
| public float sizeY; | |
| public float sizeZ; | |
| public float ballastFactor; | |
| public float inputWatts; | |
| /// <summary> | |
| /// A lat-long array of degree angles and their associated candela values. | |
| /// </summary> | |
| public AngleCandela[,] angleCandelas; | |
| public IesData () | |
| { | |
| keywords = new Dictionary<string, string> (); | |
| } | |
| } | |
| public class IesCubemap | |
| { | |
| public readonly int resolution; | |
| public readonly Dictionary<CubeFace, IesTexture> textures; | |
| public IesCubemap (int resolution) | |
| { | |
| this.resolution = resolution; | |
| this.textures = new Dictionary<CubeFace, IesTexture> (); | |
| textures.Add (CubeFace.Right, new IESTools.IesTexture (resolution, resolution)); | |
| textures.Add (CubeFace.Left, new IESTools.IesTexture (resolution, resolution)); | |
| textures.Add (CubeFace.Top, new IESTools.IesTexture (resolution, resolution)); | |
| textures.Add (CubeFace.Bottom, new IESTools.IesTexture (resolution, resolution)); | |
| textures.Add (CubeFace.Front, new IESTools.IesTexture (resolution, resolution)); | |
| textures.Add (CubeFace.Back, new IESTools.IesTexture (resolution, resolution)); | |
| } | |
| /// <summary> | |
| /// Map a 2d point on a given face of a unit cube to a corresponding point on a unit sphere. | |
| /// </summary> | |
| /// <returns>The to sphere point.</returns> | |
| public static Vec3 CubeToSpherePoint (CubeFace face, double x, double y) | |
| { | |
| switch (face) { | |
| case CubeFace.Front: | |
| return CubeToSpherePoint (x, y, -0.5); | |
| case CubeFace.Back: | |
| return CubeToSpherePoint (-x, y, 0.5); | |
| case CubeFace.Left: | |
| return CubeToSpherePoint (-0.5, y, x); | |
| case CubeFace.Right: | |
| return CubeToSpherePoint (0.5, y, -x); | |
| case CubeFace.Top: | |
| return CubeToSpherePoint (x, 0.5, y); | |
| case CubeFace.Bottom: | |
| return CubeToSpherePoint (x, -0.5, -y); | |
| default: | |
| return new Vec3 (0, 0, 0); | |
| } | |
| } | |
| /// <summary> | |
| /// Map a point on the surface of a unit cube onto the surface of a unit sphere. | |
| /// </summary> | |
| public static Vec3 CubeToSpherePoint (double x, double y, double z) | |
| { | |
| Vec3 point = new Vec3 (); | |
| point.x = x * Math.Sqrt (1 - (y * y) / 2 - (z * z) / 2 + (y * y * z * z) / 3); | |
| point.y = y * Math.Sqrt (1 - (z * z) / 2 - (x * x) / 2 + (z * z * x * x) / 3); | |
| point.z = z * Math.Sqrt (1 - (x * x) / 2 - (y * y) / 2 + (x * x * y * y) / 3); | |
| return point; | |
| } | |
| } | |
| public struct AngleCandela | |
| { | |
| public float horizontalAngle; | |
| public float verticalAngle; | |
| public float candela; | |
| } | |
| /// <summary> | |
| /// Lattitude-Longitude coordinate in radians. | |
| /// </summary> | |
| public struct LatLon | |
| { | |
| /// <summary> | |
| /// The latitude in radians. | |
| /// </summary> | |
| public readonly double latitude; | |
| /// <summary> | |
| /// The longitude in radians. | |
| /// </summary> | |
| public readonly double longitude; | |
| public LatLon (double latitude, double longitude) | |
| { | |
| this.latitude = latitude; | |
| this.longitude = longitude; | |
| } | |
| public static LatLon FromSpherePoint (Vec3 point, float radius = 1) | |
| { | |
| double lat = Math.Acos (point.y / radius); // theta | |
| double lon = Math.Atan (point.x / point.z); // phi | |
| return new LatLon (lat, lon); | |
| } | |
| } | |
| public enum CubeFace { | |
| Right, | |
| Left, | |
| Top, | |
| Bottom, | |
| Front, | |
| Back | |
| } | |
| public struct Vec3 | |
| { | |
| public double x; | |
| public double y; | |
| public double z; | |
| public Vec3 (double x, double y, double z) | |
| { | |
| this.x = x; | |
| this.y = y; | |
| this.z = z; | |
| } | |
| } | |
| class MainClass | |
| { | |
| public static void Main (string[] args) | |
| { | |
| if (args.Length == 1) { | |
| var path = args [0]; | |
| if (System.IO.File.Exists (path)) { | |
| var parser = new IesParser (path); | |
| var ies = parser.Parse (); | |
| DisplayIesData (ies); | |
| } else { | |
| System.Console.WriteLine (); | |
| System.Console.WriteLine ("Not a valid IES file"); | |
| System.Console.WriteLine (); | |
| } | |
| } else { | |
| Console.WriteLine ("Please specify a path to an IES file"); | |
| } | |
| } | |
| 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 (); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment