예제 #1
0
파일: Line.cs 프로젝트: yodiz/CarbonFitness
 public IEnumerator<ValuePoint> GetEnumerator()
 {
     if (lineEnumerator == null) {
         lineEnumerator = new LineEnumerator(this);
     }
     return lineEnumerator;
 }
예제 #2
0
 public IEnumerable <TRow> Rows()
 {
     while (LineEnumerator.MoveNext())
     {
         yield return(Mapper.MakeRow(LineEnumerator.Current));
     }
 }
예제 #3
0
    public void FindIntersections(List <Vector3> intersections)
    {
        mIntersections = intersections;
        LineEnumerator iter = new LineEnumerator(this);

        while (Process(iter))
        {
            ;
        }
    }
예제 #4
0
 public CsvReader(Stream stream, bool isHeaderIncluded, char delimeter, CsvMapper mapper)
 {
     this.Mapper    = mapper;
     LineEnumerator = RowReader(stream, delimeter).GetEnumerator();
     if (isHeaderIncluded)
     {
         LineEnumerator.MoveNext();
         mapper.ColumnNames = LineEnumerator.Current;
     }
 }
예제 #5
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    LineEnumerator?.Dispose();
                    DataRowEnumerator?.Dispose();
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }
예제 #6
0
    public IEnumerator ShowIntersections()
    {
        mIntersections = new List <Vector3>();
        LineEnumerator iter = new LineEnumerator(this);

        while (Process(iter))
        {
            Display();
            yield return(new WaitForEndOfFrame());

            yield return(new WaitForEndOfFrame());

            yield return(new WaitForEndOfFrame());

            yield return(new WaitForEndOfFrame());
        }
        Display();
    }
예제 #7
0
        private static string toJson(Dictionary <string, ValueAndType> dict,
                                     List <string> fields)
        {
            var json = s_builder;

            json.Clear();
            json.Append("{");
            json.Append("\n");
            var tab = TAB;

            int pairCount = 0;

            foreach (var field in fields)
            {
                json.Append(tab);

                if (string.IsNullOrEmpty(field))
                {
                    // Invalid in field list indicates a line break.
                    json.Append("\n");
                }
                else
                {
                    ValueAndType valueAndType;
                    if (dict.TryGetValue(field, out valueAndType))
                    {
                        var value = valueAndType.value;
                        var type  = valueAndType.type;

                        json.Append("\"");
                        json.Append(field);
                        json.Append("\": ");

                        if (type == typeof(bool))
                        {
                            json.Append(value);
                        }
                        else if (type == typeof(int))
                        {
                            json.Append(value);
                        }
                        else if (type == typeof(float))
                        {
                            json.Append(value);
                        }
                        else
                        { // type == typeof(string)
                          // If the value is itself json, correct indentation and append.
                            var trimmedValue = value.TrimStart();
                            if (trimmedValue.StartsWith("{") ||
                                trimmedValue.StartsWith("["))
                            {
                                bool onFirstLine    = true;
                                var  lineEnumerator = new LineEnumerator(value);
                                while (lineEnumerator.MoveNext())
                                {
                                    var line = lineEnumerator.Current;
                                    if (onFirstLine)
                                    {
                                        json.Append(line.Trim());
                                        onFirstLine = false;
                                    }
                                    else
                                    {
                                        json.Append(line);
                                    }

                                    if (!lineEnumerator.OnLastLine())
                                    {
                                        json.Append("\n");
                                    }
                                }
                            }
                            else
                            {
                                // Not json, so it must be an actual string; append that
                                // instead, with quotes.
                                json.Append("\"" + value + "\"");
                            }
                        }

                        if (pairCount != fields.Count - 1)
                        {
                            json.Append(",");
                        }
                        json.Append("\n");
                    }
                    else
                    {
                        Debug.LogError("State mismatch. The field " + field + " in "
                                       + "the fields list had no corresponding value in the "
                                       + "config dictionary.");
                    }
                }

                pairCount++;
            }

            json.Append("}");
            json.Append("\n");
            return(json.ToString());
        }
예제 #8
0
    public bool Process(LineEnumerator lineiter)
    {
        if (mEventQ.Count == 0)
        {
            return(false);
        }
        LineEvent          e     = mEventQ.Min;
        Vector3            isect = new Vector3();
        LineSegment        bottomNeighbor;
        LineSegment        topNeighbor;
        float              curX      = e.Point.x;
        List <LineSegment> collected = CollectLines(e);

        if (collected.Count > 1)
        {
            MarkIntersection(e.Point);
        }
        for (int i = 0; i < collected.Count; ++i)
        {
            LineSegment l = collected[i];
            if (l.End == e.Point)
            {
                RemoveActive(l);
                collected.RemoveAt(i);
            }
        }
        if (collected.Count == 0)
        {
            mCompareLines.CurrentX = curX;
            bottomNeighbor         = lineiter.FindBottomNeighbor(e.Line);
            topNeighbor            = lineiter.FindTopNeighbor(e.Line);
            if ((bottomNeighbor != null) &&
                (topNeighbor != null) &&
                (bottomNeighbor.FindIntersection(topNeighbor, ref isect) > 0))
            {
                AddIsectEvent(bottomNeighbor, topNeighbor, isect);
            }
        }
        else
        {
            foreach (LineSegment l in collected)
            {
                RemoveActive(l);
            }
            mCompareLines.CurrentX = curX;
            foreach (LineSegment l in collected)
            {
                AddActive(l);
            }
            LineSegment bottom = collected[0];
            LineSegment top    = collected[collected.Count - 1];
            bottomNeighbor = lineiter.FindBottomNeighbor(bottom);
            topNeighbor    = lineiter.FindTopNeighbor(top);

            if ((bottomNeighbor != null) &&
                (bottomNeighbor.FindIntersection(bottom, ref isect) > 0))
            {
                AddIsectEvent(bottomNeighbor, bottom, isect);
            }
            if ((topNeighbor != null) &&
                (topNeighbor.FindIntersection(top, ref isect) > 0))
            {
                AddIsectEvent(top, topNeighbor, isect);
                if ((bottomNeighbor != null) &&
                    (bottomNeighbor.FindIntersection(topNeighbor, ref isect) > 0))
                {
                    RemoveIsectEvent(bottomNeighbor, topNeighbor, isect);
                }
            }
        }
        return(true);
    }
예제 #9
0
 internal LineEnumerable(LineEnumerator enumerator)
 {
     _enumerator = enumerator;
 }