Exemplo n.º 1
0
        public bool LinearSearchForward(NodeMatch pMatchMethod)
        {
            bool           tmpMatchFound  = false;
            TimeSpanMetric tmpSearchTimer = new TimeSpanMetric();

            if (this._LogSearch)
            {
                tmpSearchTimer.Start();
            }

            try
            {
                if (this.Count > 0)
                {
                    //Now walk through the list until we either find it or hit the end.
                    while ((!pMatchMethod.Match(this.CurrentNode)) && (!this.EOL))
                    {
                        this.MoveNext();
                    }

                    //See if we found it or not
                    if (pMatchMethod.Match(this.CurrentNode))
                    {
                        this._SearchMatchCount++;
                        tmpMatchFound = true;
                    }
                }
            }
            catch
            {
                this.WriteToLog("Error during forward linear searching list of (" + this.Count.ToString() + ") items");
            }
            finally
            {
                if (this._LogSearch)
                {
                    tmpSearchTimer.Time_Stamp();
                    if (tmpMatchFound)
                    {
                        this.WriteToLog("Searched Forward in a list of (" + this.Count.ToString() + ") items and found item #" + this.CurrentNodeIndex.ToString() + " taking " + tmpSearchTimer.TimeDifference.ToString() + "ms.");
                    }
                    else
                    {
                        this.WriteToLog("Searched Forward in a list of (" + this.Count.ToString() + ") items and did not get a match taking " + tmpSearchTimer.TimeDifference.ToString() + "ms.");
                    }
                }
            }

            return(tmpMatchFound);
        }
Exemplo n.º 2
0
        private void RenderFullVisual()
        {
            this.WriteToLog("*** Visually Hinted Image Computation Beginning ***");
            this.WriteToLog(this._RenderingEngine.Name + " " + this._RenderingEngine.ParameterSerialization);
            TimeSpanMetric tmpRenderTimer = new TimeSpanMetric();

            int    tmpScreenXCounter, tmpScreenYCounter;
            double tmpChaosXCounter, tmpChaosYCounter;
            double tmpChaosXIncrement, tmpChaosYIncrement;
            int    tmpTotalPixelCount, tmpCurrentPixelCount;

            //A thread-safe container for the display refresh event
            IdleHandler tmpIdleMessageRefreshContainer = new IdleHandler(this.RefreshDisplaySafe);

            this._RenderingEngine.RenderBegin();

            //Compute the Pixel to Chaos space ratio
            tmpChaosXIncrement = (double)((this._RenderingEngine.ChaosMaxX - this._RenderingEngine.ChaosMinX) / (double)_OutputPort.Width);
            //Chaos_Y_Incriment = (double)((this.Rendering_Engine.Chaos_Max_Y - this.Rendering_Engine.Chaos_Min_Y) / (double)Output_Port.Height );
            tmpChaosYIncrement = tmpChaosXIncrement;

            //Compute the pixel counter for the progress bar.
            tmpTotalPixelCount   = _OutputPort.Width * _OutputPort.Height;
            tmpCurrentPixelCount = 0;

            _OutputPort.LastXOrigin = this._RenderingEngine.ChaosMinX;
            _OutputPort.LastYOrigin = this._RenderingEngine.ChaosMinY;
            _OutputPort.LastXRatio  = tmpChaosXIncrement;
            _OutputPort.LastYRatio  = tmpChaosYIncrement;
            this._RenderingEngine.CurrentRenderRatio = tmpChaosXIncrement;

            //Clear the render port
            for (tmpScreenXCounter = 0; tmpScreenXCounter < _OutputPort.Width; tmpScreenXCounter++)
            {
                for (tmpScreenYCounter = 0; tmpScreenYCounter < _OutputPort.Height; tmpScreenYCounter++)
                {
                    _OutputPort.MarkPixel(tmpScreenXCounter, tmpScreenYCounter, -1);
                }
            }

            this.WriteToLog(" --> Viewport Cleared");
            //Refresh the display
            Gdk.Threads.Enter();
            GLib.Idle.Add(tmpIdleMessageRefreshContainer);
            Gdk.Threads.Leave();

            //Now render a quad fractal preview
            tmpChaosXCounter = this._RenderingEngine.ChaosMinX;
            for (tmpScreenXCounter = 0; tmpScreenXCounter < _OutputPort.Width; tmpScreenXCounter++)
            {
                tmpChaosYCounter = this._RenderingEngine.ChaosMinY;
                for (tmpScreenYCounter = 0; tmpScreenYCounter < _OutputPort.Height; tmpScreenYCounter++)
                {
                    if ((tmpScreenXCounter % 2 == 0) && (tmpScreenYCounter % 2 == 0))
                    {
                        _OutputPort.MarkPixelQuad(tmpScreenXCounter, tmpScreenYCounter, this._RenderingEngine.RenderPixel(tmpChaosXCounter, tmpChaosYCounter));
                        tmpCurrentPixelCount++;
                    }

                    //if ( Current_Pixel_Counter % (this.Output_Port.Width*4) == 1 )
                    //{
                    this._RenderProgressAmount = ((double)tmpCurrentPixelCount / (double)tmpTotalPixelCount);
                    //}

                    tmpChaosYCounter += tmpChaosXIncrement;
                }

                tmpChaosXCounter += tmpChaosYIncrement;
            }

            this.WriteToLog(" --> Quad 0,0 Done [" + tmpCurrentPixelCount.ToString() + "/" + tmpTotalPixelCount.ToString() + "]");
            //Refresh the display
            Gdk.Threads.Enter();
            GLib.Idle.Add(tmpIdleMessageRefreshContainer);
            Gdk.Threads.Leave();

            //Now render the 1,1 fractal set
            tmpChaosXCounter = this._RenderingEngine.ChaosMinX;
            for (tmpScreenXCounter = 0; tmpScreenXCounter < _OutputPort.Width; tmpScreenXCounter++)
            {
                tmpChaosYCounter = this._RenderingEngine.ChaosMinY;
                for (tmpScreenYCounter = 0; tmpScreenYCounter < _OutputPort.Height; tmpScreenYCounter++)
                {
                    if ((tmpScreenXCounter % 2 == 1) && (tmpScreenYCounter % 2 == 1))
                    {
                        _OutputPort.MarkPixel(tmpScreenXCounter, tmpScreenYCounter, this._RenderingEngine.RenderPixel(tmpChaosXCounter, tmpChaosYCounter));
                        tmpCurrentPixelCount++;
                    }

                    this._RenderProgressAmount = ((double)tmpCurrentPixelCount / (double)tmpTotalPixelCount);

                    tmpChaosYCounter += tmpChaosXIncrement;
                }

                tmpChaosXCounter += tmpChaosYIncrement;
            }

            this.WriteToLog(" --> Subquad 1,1 Done [" + tmpCurrentPixelCount.ToString() + "/" + tmpTotalPixelCount.ToString() + "]");

            //Refresh the display
            Gdk.Threads.Enter();
            GLib.Idle.Add(tmpIdleMessageRefreshContainer);
            Gdk.Threads.Leave();

            //Now render the 1,0 fractal set
            tmpChaosXCounter = this._RenderingEngine.ChaosMinX;
            for (tmpScreenXCounter = 0; tmpScreenXCounter < _OutputPort.Width; tmpScreenXCounter++)
            {
                tmpChaosYCounter = this._RenderingEngine.ChaosMinY;
                for (tmpScreenYCounter = 0; tmpScreenYCounter < _OutputPort.Height; tmpScreenYCounter++)
                {
                    if ((tmpScreenXCounter % 2 == 1) && (tmpScreenYCounter % 2 == 0))
                    {
                        _OutputPort.MarkPixel(tmpScreenXCounter, tmpScreenYCounter, this._RenderingEngine.RenderPixel(tmpChaosXCounter, tmpChaosYCounter));
                        tmpCurrentPixelCount++;
                    }

                    this._RenderProgressAmount = ((double)tmpCurrentPixelCount / (double)tmpTotalPixelCount);

                    tmpChaosYCounter += tmpChaosXIncrement;
                }

                tmpChaosXCounter += tmpChaosYIncrement;
            }

            this.WriteToLog(" --> Subquad 1,0 Done [" + tmpCurrentPixelCount.ToString() + "/" + tmpTotalPixelCount.ToString() + "]");
            //Refresh the display
            Gdk.Threads.Enter();
            GLib.Idle.Add(tmpIdleMessageRefreshContainer);
            Gdk.Threads.Leave();

            //Now render the 0,1 fractal set
            tmpChaosXCounter = this._RenderingEngine.ChaosMinX;
            for (tmpScreenXCounter = 0; tmpScreenXCounter < _OutputPort.Width; tmpScreenXCounter++)
            {
                tmpChaosYCounter = this._RenderingEngine.ChaosMinY;
                for (tmpScreenYCounter = 0; tmpScreenYCounter < _OutputPort.Height; tmpScreenYCounter++)
                {
                    if ((tmpScreenXCounter % 2 == 0) && (tmpScreenYCounter % 2 == 1))
                    {
                        _OutputPort.MarkPixel(tmpScreenXCounter, tmpScreenYCounter, this._RenderingEngine.RenderPixel(tmpChaosXCounter, tmpChaosYCounter));
                        tmpCurrentPixelCount++;
                    }

                    //if ( Current_Pixel_Counter % (this.Output_Port.Width*4) == 1 )
                    //{
                    this._RenderProgressAmount = ((double)tmpCurrentPixelCount / (double)tmpTotalPixelCount);
                    //}

                    tmpChaosYCounter += tmpChaosXIncrement;
                }

                tmpChaosXCounter += tmpChaosYIncrement;
            }

            this.WriteToLog(" --> Subquad 0,1 Done [" + tmpCurrentPixelCount.ToString() + "/" + tmpTotalPixelCount.ToString() + "]");

            //Refresh the display
            Gdk.Threads.Enter();
            GLib.Idle.Add(tmpIdleMessageRefreshContainer);
            Gdk.Threads.Leave();


            this._RenderingEngine.Render_End();

            //Update the progress at 100%
            this._RenderProgressAmount = 1;

            tmpRenderTimer.Time_Stamp();
            this.WriteToLog("*** Image Computation Complete (" + tmpRenderTimer.TimeDifference.ToString() + "ms) ***");
            this._CurrentlyRendering = false;
        }
Exemplo n.º 3
0
        private void RenderFull()
        {
            this.WriteToLog("*** Silent Image Computation Beginning ***");
            this.WriteToLog(this._RenderingEngine.Name + " " + this._RenderingEngine.ParameterSerialization);
            TimeSpanMetric tmpComputationTimer = new TimeSpanMetric();

            int    tmpScreenXCounter, tmpScreenYCounter;
            double tmpChaosXCounter, tmpChaosYCounter;
            double tmpChaosXIncrement, tmpChaosYIncrement;
            int    tmpTotalPixelCount, tmpCurrentPixelCounter;

            //A thread-safe container for the display refresh event
            IdleHandler tmpIdleMessageRefreshContainer = new IdleHandler(this.RefreshDisplaySafe);

            this._RenderingEngine.RenderBegin();

            //Compute the Pixel to Chaos space ratio
            tmpChaosXIncrement = (double)((this._RenderingEngine.ChaosMaxX - this._RenderingEngine.ChaosMinX) / (double)_OutputPort.Width);
            //Chaos_Y_Incriment = (double)((this.Rendering_Engine.Chaos_Max_Y - this.Rendering_Engine.Chaos_Min_Y) / (double)Output_Port.Height );
            tmpChaosYIncrement = tmpChaosXIncrement;

            //Compute the pixel counter for the progress bar.
            tmpTotalPixelCount     = _OutputPort.Width * _OutputPort.Height;
            tmpCurrentPixelCounter = 0;

            _OutputPort.LastXOrigin = this._RenderingEngine.ChaosMinX;
            _OutputPort.LastYOrigin = this._RenderingEngine.ChaosMinY;
            _OutputPort.LastXRatio  = tmpChaosXIncrement;
            _OutputPort.LastYRatio  = tmpChaosYIncrement;
            this._RenderingEngine.CurrentRenderRatio = tmpChaosXIncrement;

            tmpChaosXCounter = this._RenderingEngine.ChaosMinX;
            for (tmpScreenXCounter = 0; tmpScreenXCounter < _OutputPort.Width; tmpScreenXCounter++)
            {
                tmpChaosYCounter = this._RenderingEngine.ChaosMinY;
                for (tmpScreenYCounter = 0; tmpScreenYCounter < _OutputPort.Height; tmpScreenYCounter++)
                {
                    if (this._QuadSampling)
                    {
                        if ((tmpScreenXCounter % 2 == 0) && (tmpScreenYCounter % 2 == 0))
                        {
                            _OutputPort.MarkPixelQuad(tmpScreenXCounter, tmpScreenYCounter, this._RenderingEngine.RenderPixel(tmpChaosXCounter, tmpChaosYCounter));
                        }
                        tmpCurrentPixelCounter++;
                    }
                    else
                    {
                        _OutputPort.MarkPixel(tmpScreenXCounter, tmpScreenYCounter, this._RenderingEngine.RenderPixel(tmpChaosXCounter, tmpChaosYCounter));

                        tmpCurrentPixelCounter++;
                    }

                    //if ( Current_Pixel_Counter % (this.Output_Port.Width*4) == 1 )
                    //{
                    this._RenderProgressAmount = ((double)tmpCurrentPixelCounter / (double)tmpTotalPixelCount);
                    //}

                    tmpChaosYCounter += tmpChaosXIncrement;
                }

                tmpChaosXCounter += tmpChaosYIncrement;
            }

            this._RenderingEngine.Render_End();

            //It's now safe to refresh the display and such.
            Gdk.Threads.Enter();
            GLib.Idle.Add(tmpIdleMessageRefreshContainer);
            Gdk.Threads.Leave();


            //Update the progress at 100%
            this._RenderProgressAmount = 1;

            tmpComputationTimer.Time_Stamp();
            this.WriteToLog("*** Image Computation Complete (" + tmpComputationTimer.TimeDifference.ToString() + "ms) ***");
            this._CurrentlyRendering = false;
        }