public AnalysisPointImage(OpticalSystem system)
 {
     _system          = system;
     _tracer          = new RayTracer();
     _processed_trace = false;
     _image           = null;
     _intercepts      = new List <TracedRay>();
     _params          = new RayTraceParameters(system);
     _params.set_default_distribution(
         new Distribution(Pattern.HexaPolarDist, 20, 0.999));
     _params.get_default_distribution().set_uniform_pattern();
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Args arguments = Args.parseArguments(args);

            if (arguments.filename == null)
            {
                Console.WriteLine("Usage: --specfile inputfile [--scenario num] [--skew] [--output layout|spot] [--dump-system]");
                Environment.Exit(1);
            }
            OpticalBenchDataImporter.LensSpecifications specs = new OpticalBenchDataImporter.LensSpecifications();
            specs.parse_file(arguments.filename);
            OpticalSystem.Builder systemBuilder = OpticalBenchDataImporter.buildSystem(specs, arguments.scenario);
            double  angleOfView = OpticalBenchDataImporter.getAngleOfViewInRadians(specs, arguments.scenario);
            Vector3 direction   = Vector3.vector3_001;

            if (arguments.skewRays)
            {
                // Construct unit vector at an angle
                //      double z1 = cos (angleOfView);
                //      double y1 = sin (angleOfView);
                //      unit_vector = math::Vector3 (0, y1, z1);
                Matrix3 r = Matrix3.get_rotation_matrix(0, angleOfView);
                direction = r.times(direction);
            }

            PointSource.Builder ps = new PointSource.Builder(PointSource.SourceInfinityMode.SourceAtInfinity, direction)
                                     .add_spectral_line(SpectralLine.d)
                                     .add_spectral_line(SpectralLine.C)
                                     .add_spectral_line(SpectralLine.F);
            systemBuilder.add(ps);

            OpticalSystem system = systemBuilder.build();

            if (arguments.dumpSystem)
            {
                Console.WriteLine(system);
            }
            if (arguments.outputType.Equals("layout"))
            {
                RendererSvg renderer = new RendererSvg(800, 400);
                // draw 2d system layout
                SystemLayout2D systemLayout2D = new SystemLayout2D();
                systemLayout2D.layout2d(renderer, system);

                RayTraceParameters parameters = new RayTraceParameters(system);

                RayTracer rayTracer = new RayTracer();
                parameters.set_default_distribution(
                    new Distribution(Pattern.MeridionalDist, 10, 0.999));
                // TODO set save generated state on point source
                if (arguments.dumpSystem)
                {
                    Console.WriteLine(parameters.sequenceToString(new StringBuilder()).ToString());
                }
                RayTraceResults result = rayTracer.trace(system, parameters);
                RayTraceRenderer.draw_2d(renderer, result, false, null);
                Console.WriteLine(renderer.write(new StringBuilder()).ToString());
            }
            if (arguments.outputType.Equals("spot"))
            {
                RendererSvg renderer = new RendererSvg(300, 300, Rgb.rgb_black);
                renderer = new RendererSvg(300, 300, Rgb.rgb_black);
                AnalysisSpot spot = new AnalysisSpot(system);
                spot.draw_diagram(renderer, true);
                Console.WriteLine(renderer.write(new StringBuilder()).ToString());
            }
        }