Пример #1
0
        public override int GetHashCode()
        {
            int hashcode = 157;

            unchecked {
                if (__isset.primitiveEntry)
                {
                    hashcode = (hashcode * 397) + PrimitiveEntry.GetHashCode();
                }
                if (__isset.arrayEntry)
                {
                    hashcode = (hashcode * 397) + ArrayEntry.GetHashCode();
                }
                if (__isset.mapEntry)
                {
                    hashcode = (hashcode * 397) + MapEntry.GetHashCode();
                }
                if (__isset.structEntry)
                {
                    hashcode = (hashcode * 397) + StructEntry.GetHashCode();
                }
                if (__isset.unionEntry)
                {
                    hashcode = (hashcode * 397) + UnionEntry.GetHashCode();
                }
                if (__isset.userDefinedTypeEntry)
                {
                    hashcode = (hashcode * 397) + UserDefinedTypeEntry.GetHashCode();
                }
            }
            return(hashcode);
        }
Пример #2
0
 private QuantifierEntry(PrimitiveEntry primitiveEntry, QuantifierKind kind, QuantifierMode mode, int maximum, int minimum)
 {
     Kind           = kind;
     Mode           = mode;
     PrimitiveEntry = primitiveEntry;
     Maximum        = maximum;
     Minimum        = minimum;
 }
Пример #3
0
            public QuantifierEntry(PrimitiveEntry primitiveEntry, Interval <int> range, QuantifierMode mode)
            {
                PrimitiveEntry = primitiveEntry;
                Kind           = QuantifierHelper.GetKind(range);
                Mode           = mode;

                Minimum = range.Minimum;
                Maximum = range.Maximum;
            }
Пример #4
0
        public void Draw(Vector2 shape, Color color)
        {
            PrepareGroup();

            var e = new PrimitiveEntry();

            e.Point = shape;
            e.Type  = PrimitiveType.Points;
            e.Color = color;
            currentBatch.Entries.Add(e);
        }
Пример #5
0
        public void DrawFilled(RectangleF shape, Color color)
        {
            PrepareGroup();

            var e = new PrimitiveEntry();

            e.Rect  = shape;
            e.Type  = PrimitiveType.FilledQuads;
            e.Color = color;
            currentBatch.Entries.Add(e);
        }
Пример #6
0
            public QuantifierEntry(PrimitiveEntry primitiveEntry, QuantifierKind kind, QuantifierMode mode)
            {
                PrimitiveEntry = primitiveEntry;
                Kind           = kind;
                Mode           = mode;

                var range = QuantifierHelper.GetRange(kind);

                Minimum = range.Minimum;
                Maximum = range.Maximum;
            }
Пример #7
0
        public void Draw(Polygon shape, Color color)
        {
            PrepareGroup();

            var e = new PrimitiveEntry();

            e.Polygon = shape;
            e.Type    = PrimitiveType.Polygon;
            e.Color   = color;
            currentBatch.Entries.Add(e);
        }
Пример #8
0
        public void DrawFilled(Circle shape, Color color)
        {
            PrepareGroup();

            var e = new PrimitiveEntry();

            e.Circle = shape;
            e.Type   = PrimitiveType.FilledCircles;
            e.Color  = color;
            currentBatch.Entries.Add(e);
        }
Пример #9
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder("TTypeEntry(");

            sb.Append("PrimitiveEntry: ");
            sb.Append(PrimitiveEntry == null ? "<null>" : PrimitiveEntry.ToString());
            sb.Append(",ArrayEntry: ");
            sb.Append(ArrayEntry == null ? "<null>" : ArrayEntry.ToString());
            sb.Append(",MapEntry: ");
            sb.Append(MapEntry == null ? "<null>" : MapEntry.ToString());
            sb.Append(",StructEntry: ");
            sb.Append(StructEntry == null ? "<null>" : StructEntry.ToString());
            sb.Append(",UnionEntry: ");
            sb.Append(UnionEntry == null ? "<null>" : UnionEntry.ToString());
            sb.Append(",UserDefinedTypeEntry: ");
            sb.Append(UserDefinedTypeEntry == null ? "<null>" : UserDefinedTypeEntry.ToString());
            sb.Append(")");
            return(sb.ToString());
        }
Пример #10
0
        private BeginMode GetMode(PrimitiveEntry entry)
        {
            switch (entry.Type)
            {
            case PrimitiveType.Points: return(BeginMode.Points);

            case PrimitiveType.Lines: return(BeginMode.Lines);

            case PrimitiveType.Quads: return(BeginMode.Lines);

            case PrimitiveType.Polygon: return(BeginMode.Lines);

            case PrimitiveType.FilledQuads: return(BeginMode.Triangles);

            case PrimitiveType.Circles: return(BeginMode.Lines);

            case PrimitiveType.FilledCircles: return(BeginMode.Triangles);
            }

            Debug.Assert(false);
            return(BeginMode.Points);
        }
Пример #11
0
        public async Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
        {
            oprot.IncrementRecursionDepth();
            try
            {
                var struc = new TStruct("TTypeEntry");
                await oprot.WriteStructBeginAsync(struc, cancellationToken);

                var field = new TField();
                if (PrimitiveEntry != null && __isset.primitiveEntry)
                {
                    field.Name = "primitiveEntry";
                    field.Type = TType.Struct;
                    field.ID   = 1;
                    await oprot.WriteFieldBeginAsync(field, cancellationToken);

                    await PrimitiveEntry.WriteAsync(oprot, cancellationToken);

                    await oprot.WriteFieldEndAsync(cancellationToken);
                }
                if (ArrayEntry != null && __isset.arrayEntry)
                {
                    field.Name = "arrayEntry";
                    field.Type = TType.Struct;
                    field.ID   = 2;
                    await oprot.WriteFieldBeginAsync(field, cancellationToken);

                    await ArrayEntry.WriteAsync(oprot, cancellationToken);

                    await oprot.WriteFieldEndAsync(cancellationToken);
                }
                if (MapEntry != null && __isset.mapEntry)
                {
                    field.Name = "mapEntry";
                    field.Type = TType.Struct;
                    field.ID   = 3;
                    await oprot.WriteFieldBeginAsync(field, cancellationToken);

                    await MapEntry.WriteAsync(oprot, cancellationToken);

                    await oprot.WriteFieldEndAsync(cancellationToken);
                }
                if (StructEntry != null && __isset.structEntry)
                {
                    field.Name = "structEntry";
                    field.Type = TType.Struct;
                    field.ID   = 4;
                    await oprot.WriteFieldBeginAsync(field, cancellationToken);

                    await StructEntry.WriteAsync(oprot, cancellationToken);

                    await oprot.WriteFieldEndAsync(cancellationToken);
                }
                if (UnionEntry != null && __isset.unionEntry)
                {
                    field.Name = "unionEntry";
                    field.Type = TType.Struct;
                    field.ID   = 5;
                    await oprot.WriteFieldBeginAsync(field, cancellationToken);

                    await UnionEntry.WriteAsync(oprot, cancellationToken);

                    await oprot.WriteFieldEndAsync(cancellationToken);
                }
                if (UserDefinedTypeEntry != null && __isset.userDefinedTypeEntry)
                {
                    field.Name = "userDefinedTypeEntry";
                    field.Type = TType.Struct;
                    field.ID   = 6;
                    await oprot.WriteFieldBeginAsync(field, cancellationToken);

                    await UserDefinedTypeEntry.WriteAsync(oprot, cancellationToken);

                    await oprot.WriteFieldEndAsync(cancellationToken);
                }
                await oprot.WriteFieldStopAsync(cancellationToken);

                await oprot.WriteStructEndAsync(cancellationToken);
            }
            finally
            {
                oprot.DecrementRecursionDepth();
            }
        }
Пример #12
0
        public override string ToString()
        {
            var  sb      = new StringBuilder("TTypeEntry(");
            bool __first = true;

            if (PrimitiveEntry != null && __isset.primitiveEntry)
            {
                if (!__first)
                {
                    sb.Append(", ");
                }
                __first = false;
                sb.Append("PrimitiveEntry: ");
                sb.Append(PrimitiveEntry == null ? "<null>" : PrimitiveEntry.ToString());
            }
            if (ArrayEntry != null && __isset.arrayEntry)
            {
                if (!__first)
                {
                    sb.Append(", ");
                }
                __first = false;
                sb.Append("ArrayEntry: ");
                sb.Append(ArrayEntry == null ? "<null>" : ArrayEntry.ToString());
            }
            if (MapEntry != null && __isset.mapEntry)
            {
                if (!__first)
                {
                    sb.Append(", ");
                }
                __first = false;
                sb.Append("MapEntry: ");
                sb.Append(MapEntry == null ? "<null>" : MapEntry.ToString());
            }
            if (StructEntry != null && __isset.structEntry)
            {
                if (!__first)
                {
                    sb.Append(", ");
                }
                __first = false;
                sb.Append("StructEntry: ");
                sb.Append(StructEntry == null ? "<null>" : StructEntry.ToString());
            }
            if (UnionEntry != null && __isset.unionEntry)
            {
                if (!__first)
                {
                    sb.Append(", ");
                }
                __first = false;
                sb.Append("UnionEntry: ");
                sb.Append(UnionEntry == null ? "<null>" : UnionEntry.ToString());
            }
            if (UserDefinedTypeEntry != null && __isset.userDefinedTypeEntry)
            {
                if (!__first)
                {
                    sb.Append(", ");
                }
                __first = false;
                sb.Append("UserDefinedTypeEntry: ");
                sb.Append(UserDefinedTypeEntry == null ? "<null>" : UserDefinedTypeEntry.ToString());
            }
            sb.Append(")");
            return(sb.ToString());
        }
Пример #13
0
        public void Write(TProtocol oprot)
        {
            TStruct struc = new TStruct("TTypeEntry");

            oprot.WriteStructBegin(struc);
            TField field = new TField();

            if (PrimitiveEntry != null && __isset.primitiveEntry)
            {
                field.Name = "primitiveEntry";
                field.Type = TType.Struct;
                field.ID   = 1;
                oprot.WriteFieldBegin(field);
                PrimitiveEntry.Write(oprot);
                oprot.WriteFieldEnd();
            }
            if (ArrayEntry != null && __isset.arrayEntry)
            {
                field.Name = "arrayEntry";
                field.Type = TType.Struct;
                field.ID   = 2;
                oprot.WriteFieldBegin(field);
                ArrayEntry.Write(oprot);
                oprot.WriteFieldEnd();
            }
            if (MapEntry != null && __isset.mapEntry)
            {
                field.Name = "mapEntry";
                field.Type = TType.Struct;
                field.ID   = 3;
                oprot.WriteFieldBegin(field);
                MapEntry.Write(oprot);
                oprot.WriteFieldEnd();
            }
            if (StructEntry != null && __isset.structEntry)
            {
                field.Name = "structEntry";
                field.Type = TType.Struct;
                field.ID   = 4;
                oprot.WriteFieldBegin(field);
                StructEntry.Write(oprot);
                oprot.WriteFieldEnd();
            }
            if (UnionEntry != null && __isset.unionEntry)
            {
                field.Name = "unionEntry";
                field.Type = TType.Struct;
                field.ID   = 5;
                oprot.WriteFieldBegin(field);
                UnionEntry.Write(oprot);
                oprot.WriteFieldEnd();
            }
            if (UserDefinedTypeEntry != null && __isset.userDefinedTypeEntry)
            {
                field.Name = "userDefinedTypeEntry";
                field.Type = TType.Struct;
                field.ID   = 6;
                oprot.WriteFieldBegin(field);
                UserDefinedTypeEntry.Write(oprot);
                oprot.WriteFieldEnd();
            }
            oprot.WriteFieldStop();
            oprot.WriteStructEnd();
        }
Пример #14
0
                public ParserQuantifierEntry(Grammar <TToken> .ParserQuantifierEntry grammarEntry, PrimitiveEntry primitiveEntry, Interval <int> range, QuantifierMode mode) : base(primitiveEntry, range, mode)
                {
                    var name = EnsureName(grammarEntry);

                    if (name == null)
                    {
                        return;
                    }

                    var primitiveEntryData = ((IParserEntry)PrimitiveEntry).ParserEntryData;

                    primitiveEntryData.Name = name;
                }
Пример #15
0
        private void AddEntry(PrimitiveEntry entry, ref int index)
        {
            var halfPoint   = new Vector2(0.5f, 0.5f);
            int vertexCount = 0;

            switch (entry.Type)
            {
            case PrimitiveType.Points: vertexCount = 1; break;

            case PrimitiveType.Lines: vertexCount = 2; break;

            case PrimitiveType.Quads: vertexCount = 8; break;

            case PrimitiveType.FilledQuads: vertexCount = 6; break;

            case PrimitiveType.Circles: vertexCount = 2 * GetCircleEdges(entry.Circle.Radius); break;

            case PrimitiveType.FilledCircles: vertexCount = 3 * GetCircleEdges(entry.Circle.Radius); break;

            case PrimitiveType.Polygon:
            {
                if (entry.Polygon.Count < 2)
                {
                    return;
                }
                vertexCount = entry.Polygon.Count * 2;
            }
            break;
            }

            var vertices = GetVertices(index + vertexCount);

            switch (entry.Type)
            {
            case PrimitiveType.Points:
            {
                vertices[index].Position = entry.Point + halfPoint;
                vertices[index].Color    = entry.Color;
            }
            break;

            case PrimitiveType.Lines:
            {
                vertices[index + 0].Position = entry.Line.Start + halfPoint;
                vertices[index + 1].Position = entry.Line.End + halfPoint;
                vertices[index + 0].Color    = entry.Color;
                vertices[index + 1].Color    = entry.Color;
            }
            break;

            case PrimitiveType.Quads:
            {
                vertices[index + 0].Position.X = entry.Rect.X + halfPoint.X;
                vertices[index + 0].Position.Y = entry.Rect.Y + halfPoint.Y;
                vertices[index + 1].Position.X = entry.Rect.X + halfPoint.X;
                vertices[index + 1].Position.Y = entry.Rect.Y + entry.Rect.Height - 1.0f + halfPoint.Y;

                vertices[index + 2].Position.X = vertices[index + 1].Position.X;
                vertices[index + 2].Position.Y = vertices[index + 1].Position.Y;
                vertices[index + 3].Position.X = entry.Rect.X + entry.Rect.Width - 1.0f + halfPoint.X;
                vertices[index + 3].Position.Y = entry.Rect.Y + entry.Rect.Height - 1.0f + halfPoint.Y;

                vertices[index + 4].Position.X = vertices[index + 3].Position.X;
                vertices[index + 4].Position.Y = vertices[index + 3].Position.Y;
                vertices[index + 5].Position.X = entry.Rect.X + entry.Rect.Width - 1.0f + halfPoint.X;
                vertices[index + 5].Position.Y = entry.Rect.Y + halfPoint.Y;

                vertices[index + 6].Position.X = vertices[index + 5].Position.X;
                vertices[index + 6].Position.Y = vertices[index + 5].Position.Y;
                vertices[index + 7].Position.X = vertices[index + 0].Position.X;
                vertices[index + 7].Position.Y = vertices[index + 0].Position.Y;

                vertices[index + 0].Color = entry.Color;
                vertices[index + 1].Color = entry.Color;
                vertices[index + 2].Color = entry.Color;
                vertices[index + 3].Color = entry.Color;
                vertices[index + 4].Color = entry.Color;
                vertices[index + 5].Color = entry.Color;
                vertices[index + 6].Color = entry.Color;
                vertices[index + 7].Color = entry.Color;
            }
            break;

            case PrimitiveType.Circles:
            {
                int edges = vertexCount / 2;

                vertices[index].Position = new Vector2(entry.Circle.Center.X + entry.Circle.Radius + halfPoint.X, entry.Circle.Center.Y + halfPoint.Y);
                vertices[index].Color    = entry.Color;

                for (int i = 1; i < edges; i++)
                {
                    float a = ((float)i / edges) * MathTools.TwoPi;
                    var   p = new Vector2(entry.Circle.Center.X + entry.Circle.Radius * (float)Math.Cos(a), entry.Circle.Center.Y + entry.Circle.Radius * (float)Math.Sin(a));
                    var   v = new Vertex2Color(p + halfPoint, entry.Color);

                    vertices[index + i * 2 - 1] = v;
                    vertices[index + i * 2]     = v;
                }

                vertices[index + edges * 2 - 1] = vertices[index];
            } break;

            case PrimitiveType.Polygon:
            {
                int edges = vertexCount / 2;
                vertices[index] = new Vertex2Color(entry.Polygon[0] + halfPoint, entry.Color);

                for (int i = 1; i < edges; i++)
                {
                    var p = entry.Polygon[i];
                    var v = new Vertex2Color(p + halfPoint, entry.Color);

                    vertices[index + i * 2 - 1] = v;
                    vertices[index + i * 2]     = v;
                }

                vertices[index + edges * 2 - 1] = vertices[index];
            } break;

            case PrimitiveType.FilledQuads:
            {
                vertices[index + 0].Position.X = entry.Rect.X + halfPoint.X;
                vertices[index + 0].Position.Y = entry.Rect.Y + halfPoint.Y;
                vertices[index + 1].Position.X = entry.Rect.X + halfPoint.X;
                vertices[index + 1].Position.Y = entry.Rect.Y + entry.Rect.Height - 1.0f + halfPoint.Y;
                vertices[index + 2].Position.X = entry.Rect.X + entry.Rect.Width - 1.0f + halfPoint.X;
                vertices[index + 2].Position.Y = entry.Rect.Y + halfPoint.Y;
                vertices[index + 3].Position   = vertices[index + 2].Position;
                vertices[index + 4].Position   = vertices[index + 1].Position;
                vertices[index + 5].Position.X = entry.Rect.X + entry.Rect.Width - 1.0f + halfPoint.X;
                vertices[index + 5].Position.Y = entry.Rect.Y + entry.Rect.Height - 1.0f + halfPoint.Y;

                for (int i = 0; i < vertexCount; i++)
                {
                    vertices[index + i].Color = entry.Color;
                }
            }
            break;

            case PrimitiveType.FilledCircles:
            {
                int edges = vertexCount / 3;

                var center = new Vertex2Color(entry.Circle.Center + halfPoint, entry.Color);

                vertices[index]     = new Vertex2Color(new Vector2(entry.Circle.Center.X + entry.Circle.Radius + halfPoint.X, entry.Circle.Center.Y + halfPoint.Y), entry.Color);
                vertices[index + 1] = center;

                for (int i = 1; i < edges; i++)
                {
                    float a = ((float)i / edges) * MathTools.TwoPi;
                    var   p = new Vector2(entry.Circle.Center.X + entry.Circle.Radius * (float)Math.Cos(a), entry.Circle.Center.Y + entry.Circle.Radius * (float)Math.Sin(a));
                    var   v = new Vertex2Color(p + halfPoint, entry.Color);

                    vertices[index + i * 3 - 1] = v;
                    vertices[index + i * 3]     = v;
                    vertices[index + i * 3 + 1] = center;
                }

                vertices[index + edges * 3 - 1] = vertices[index];
            } break;
            }

            index += vertexCount;
        }
Пример #16
0
 public override ParserEntry CreateParserEntry()
 {
     return(new ParserQuantifierEntry((ParserPrimitiveEntry)PrimitiveEntry.CreateParserEntry(), Kind, Mode));
 }
            private PrimitiveEntry ParsePrimitive(PrimitiveType type)
            {
                PrimitiveEntry prim = new PrimitiveEntry() { _type = type };
                PrimitiveFace p;
                int val;
                int stride = 0, elements = 0;

                switch (type)
                {
                    case PrimitiveType.trifans:
                    case PrimitiveType.tristrips:
                    case PrimitiveType.triangles:
                        stride = 3;
                        break;
                    case PrimitiveType.lines:
                    case PrimitiveType.linestrips:
                        stride = 2;
                        break;
                    case PrimitiveType.polygons:
                    case PrimitiveType.polylist:
                        stride = 4;
                        break;
                }

                while (_reader.ReadAttribute())
                    if (_reader.Name.Equals("material", true))
                        prim._material = (string)_reader.Value;
                    else if (_reader.Name.Equals("count", true))
                        prim._entryCount = int.Parse((string)_reader.Value);

                prim._faces.Capacity = prim._entryCount;

                while (_reader.BeginElement())
                {
                    if (_reader.Name.Equals("input", true))
                    {
                        prim._inputs.Add(ParseInput());
                        elements++;
                    }
                    else if (_reader.Name.Equals("p", true))
                    {
                        List<ushort> indices = new List<ushort>(stride * elements);

                        p = new PrimitiveFace();
                        //p._pointIndices.Capacity = stride * elements;
                        while (_reader.ReadValue(&val))
                            indices.Add((ushort)val);

                        p._pointCount = indices.Count / elements;
                        p._pointIndices = indices.ToArray();

                        switch (type)
                        {
                            case PrimitiveType.trifans:
                            case PrimitiveType.tristrips:
                            case PrimitiveType.polygons:
                            case PrimitiveType.polylist:
                                p._faceCount = p._pointCount - 2;
                                break;

                            case PrimitiveType.triangles:
                                p._faceCount = p._pointCount / 3;
                                break;

                            case PrimitiveType.lines:
                                p._faceCount = p._pointCount / 2;
                                break;

                            case PrimitiveType.linestrips:
                                p._faceCount = p._pointCount - 1;
                                break;
                        }

                        prim._faceCount += p._faceCount;
                        prim._pointCount += p._pointCount;
                        prim._faces.Add(p);
                    }

                    _reader.EndElement();
                }

                prim._entryStride = elements;

                return prim;
            }