Esempio n. 1
0
    EStartPoint Reverse(EStartPoint _sp)
    {
        switch (_sp)
        {
        case EStartPoint.IH:
            return(EStartPoint.IL);

        case EStartPoint.IL:
            return(EStartPoint.IH);

        case EStartPoint.UH:
            return(EStartPoint.UL);

        case EStartPoint.UL:
            return(EStartPoint.UH);
        }
        return(EStartPoint.IH);
    }
Esempio n. 2
0
        static public bool Check(IU _iu, EStartPoint _sp)
        {
            switch (_sp)
            {
            case EStartPoint.IH:
                return(_iu.I > 0);

            case EStartPoint.IL:
                return(_iu.I < 0);

            case EStartPoint.UH:
                return(_iu.U > 0);

            case EStartPoint.UL:
                return(_iu.U < 0);
            }
            return(false);
        }
Esempio n. 3
0
    bool CheckWin(int _index, EStartPoint _StartPoint)
    {
        int lstart = _index - win;
        int lstop  = _index + win;

        if (lstart < Start || lstop > Stop)
        {
            return(false);
        }
        if (Check(lstart, _StartPoint))
        {
            return(false);
        }
        if (!Check(lstop, _StartPoint))
        {
            return(false);
        }
        return(true);
    }
Esempio n. 4
0
 int FindPoint(int _start, bool _positive)
 {
     if (_positive)
     {
         for (int i = _start; i <= Stop; i++)
         {
             if (!Check(i, StartPoint))
             {
                 continue;
             }
             if (!CheckWin(i, StartPoint))
             {
                 continue;
             }
             return(i);
         }
     }
     else
     {
         EStartPoint sp = Reverse(StartPoint);
         for (int i = _start; i <= Stop; i++)
         {
             IU iui = iu[i];
             if (!Check(i, sp))
             {
                 continue;
             }
             if (!CheckWin(i, sp))
             {
                 continue;
             }
             return(i);
         }
     }
     return(-1);
 }
Esempio n. 5
0
    IEnumerator Calc0(
        SqlBoolean _pars,
        SqlString _img,
        SqlString _stresh,
        SqlInt32 _HalfPeriod,
        SqlInt32 _HalfPeriodDif,
        SqlBoolean _FullPeriod,
        SqlString _ByU,
        SqlString _ValIU,
        SqlInt32 _BorderStart,
        SqlInt32 _BorderStop,
        SqlInt32 _SOPLenght,
        SqlInt32 _SOPStart,
        SqlInt32 _SOPStop
        )
    {
        if (_img.IsNull)
        {
            yield break;
        }

        StartPoint = ParceEStartPoint(_ByU.Value);
        ValIU      = ParceEValIU(_ValIU.Value);
        iu         = IU.StrToIUfloat(_img.Value);
        periodMin  = periodMin = _HalfPeriod.Value - _HalfPeriodDif.Value;
        if (periodMin < 0)
        {
            periodMin = 0;
        }
        periodMax = _HalfPeriod.Value + _HalfPeriodDif.Value;
        if (_SOPLenght.IsNull)
        {
            if (_BorderStart.IsNull)
            {
                Start = 0;
            }
            else
            {
                Start = Convert.ToInt32(Math.Floor(Convert.ToDouble(iu.Length) * _BorderStart.Value / 100));
            }
            if (_BorderStop.IsNull)
            {
                Stop = iu.Length - 1;
            }
            else
            {
                Stop = iu.Length - 1 - Convert.ToInt32(Math.Floor(Convert.ToDouble(iu.Length) * _BorderStop.Value / 100));
            }
        }
        else
        {
            double per_mm = iu.Length;
            per_mm /= _SOPLenght.Value;
            Start   = Convert.ToInt32(Math.Ceiling(per_mm * (_SOPStart.IsNull ? 0 : _SOPStart.Value)));
            Stop    = Convert.ToInt32(Math.Ceiling(per_mm * (_SOPStop.IsNull ? 0 : _SOPStop.Value)));
            if (Start < 0)
            {
                Start = 0;
            }
            if (Stop < Start)
            {
                Stop = Start;
            }
            if (Stop > iu.Length - 1)
            {
                Stop = iu.Length - 1;
            }
        }
        FullPeriod = _FullPeriod.Value;
        win        = Convert.ToInt32(Math.Ceiling(_HalfPeriod.Value * 0.05));

        int[] tresh;
        int   treshMax;

        if (_stresh.IsNull)
        {
            tresh    = new int[0];
            treshMax = 0;
        }
        else
        {
            string[] mtresh = _stresh.Value.Split(';');
            tresh = new int[mtresh.Length];
            double k = _HalfPeriod.Value;
            k       /= 100;
            treshMax = 0;
            for (int i = 0; i < mtresh.Length; i++)
            {
                tresh[i] = (int)(k * Convert.ToDouble(mtresh[i].Replace('.', ',')));
                if (treshMax < tresh[i])
                {
                    treshMax = tresh[i];
                }
            }
        }
        double[] coords = new double[tresh.Length];
        for (int i = 0; i < tresh.Length; i++)
        {
            coords[i] = 0;
        }
        List <SGHalfPeriod> Lsghp = new List <SGHalfPeriod>();

        int      nn          = 0;
        SGPeriod prev_period = new SGPeriod()
        {
            start = Start, size = 0
        };

        for (; ;)
        {
            SGPeriod period = GetNextPeriod(prev_period);
            if (period == null)
            {
                break;
            }
            if (period.start + treshMax >= iu.Length)
            {
                break;
            }
            if (period.size > periodMax || period.size < periodMin)
            {
                prev_period = period;
                continue;
            }
            Lsghp.Add(new SGHalfPeriod(nn, period.start, period.size));
            for (int i = 0; i < coords.Length; i++)
            {
                coords[i] += iu[period.start + tresh[i]].Val(ValIU);
            }
            nn++;
            prev_period = period;
        }
        for (int i = 0; i < coords.Length; i++)
        {
            coords[i] = Math.Round(coords[i] / nn, 2);
            if (double.IsNaN(coords[i]))
            {
                coords[i] = 0;
            }
        }

        if (_pars.Value)
        {
            for (int i = 0; i < coords.Length; i++)
            {
                yield return(new Result(i, coords[i], ""));
            }
        }
        else
        {
            for (int i = 0; i < Lsghp.Count; i++)
            {
                yield return(new Result(Lsghp[i].start, Lsghp[i].size, ""));
            }
        }
    }
Esempio n. 6
0
 bool Check(int _index, EStartPoint _StartPoint)
 {
     return(IU.Check(iu[_index], _StartPoint));
 }
        internal static string RemoveFirstOccurenceSpecialCharacters(string fileName, EStartPoint startPoint, char[] specialCharacters)
        {
            char[] buffer = new char[fileName.Length];
            int    idx    = 0;
            bool   done   = false;

            switch (startPoint)
            {
            case EStartPoint.FromStart:
            {
                for (int i = 0; i < fileName.Length; i++)
                {
                    if (!done && specialCharacters.Contains(fileName[i]))
                    {
                        //do nothing
                    }
                    else
                    {
                        done          = true;
                        buffer[idx++] = fileName[i];
                    }
                }
                break;
            }

            case EStartPoint.FromEnd:
            {
                for (int i = fileName.Length - 1; i > 0; i--)
                {
                    if (!done && specialCharacters.Contains(fileName[i]))
                    {
                        //do nothing
                    }
                    else
                    {
                        done          = true;
                        buffer[idx++] = fileName[i];
                        buffer.Reverse();
                    }
                }
                break;
            }

            default:
                break;
            }
            return(new string(buffer, 0, idx));
        }