public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.Node                 = binaryReader.ReadShortBlockIndex1();
     this.Region               = binaryReader.ReadShortBlockIndex1();
     this.Permutattion         = binaryReader.ReadShortBlockIndex2();
     this.fieldpad             = binaryReader.ReadBytes(2);
     this.BoudingSphereOffset  = binaryReader.ReadVector3();
     this.BoundingSphereRadius = binaryReader.ReadSingle();
     this.RigidBodiesFlags     = ((Flags)(binaryReader.ReadInt16()));
     this.MotionType           = ((MotionTypeEnum)(binaryReader.ReadInt16()));
     this.NoPhantomPowerAlt    = binaryReader.ReadShortBlockIndex1();
     this.Size                 = ((SizeEnum)(binaryReader.ReadInt16()));
     this.InertiaTensorScale   = binaryReader.ReadSingle();
     this.LinearDamping        = binaryReader.ReadSingle();
     this.AngularDamping       = binaryReader.ReadSingle();
     this.CenterOffMassOffset  = binaryReader.ReadVector3();
     this.ShapeType            = ((ShapeTypeEnum)(binaryReader.ReadInt16()));
     this.Shape                = binaryReader.ReadShortBlockIndex2();
     this.Mass                 = binaryReader.ReadSingle();
     this.CenterOfMass         = binaryReader.ReadVector3();
     this.fieldskip            = binaryReader.ReadBytes(4);
     this.IntertiaTensorX      = binaryReader.ReadVector3();
     this.fieldskip0           = binaryReader.ReadBytes(4);
     this.IntertiaTensorY      = binaryReader.ReadVector3();
     this.fieldskip1           = binaryReader.ReadBytes(4);
     this.IntertiaTensorZ      = binaryReader.ReadVector3();
     this.fieldskip2           = binaryReader.ReadBytes(4);
     this.BoundingSpherePad    = binaryReader.ReadSingle();
     this.fieldpad0            = binaryReader.ReadBytes(12);
     return(pointerQueue);
 }
        private static void ProcessShapeArea()
        {
            Console.WriteLine("\n---------------------------------------------------------------------");
            Console.WriteLine("Do you want a square (1), circle (2), or equilateral triangle (3): ");

            var           userInputShapeType = GetUserInputInt();
            ShapeTypeEnum type = (ShapeTypeEnum)userInputShapeType;

            Console.WriteLine("Enter the shape's primary dimension (width, radius, or base): ");

            var userInputShapeWith = GetUserInputInt();

            Shape s;

            try
            {
                s = _shapeFactory.CreateShape(type, userInputShapeWith);
                var area = s.CalculateArea();
                Console.WriteLine("Shape properties:");
                Console.WriteLine("\tWidth: " + s.Width);
                Console.WriteLine("\tArea: " + area);
            }
            catch (Exception ex)
            {
                Console.WriteLine();
                Console.WriteLine("Error: {0}", ex.Message);
            }
        }
Beispiel #3
0
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.ShapeType       = ((ShapeTypeEnum)(binaryReader.ReadInt16()));
     this.Shape           = binaryReader.ReadShortBlockIndex2();
     this.CollisionFilter = binaryReader.ReadInt32();
     return(pointerQueue);
 }
Beispiel #4
0
        public static Shape GenerateShape(ShapeTypeEnum shapeType)
        {
            switch (shapeType)
            {
            case ShapeTypeEnum.I:
                return(new ShapeI());
            }

            return(null);
        }
Beispiel #5
0
        /// <summary>
        /// 读取和解析.shp文件的文件头
        /// </summary>
        private void ParseHeader()
        {
            fsShapeFile = new FileStream(_Filename, FileMode.Open, FileAccess.Read);
            brShapeFile = new BinaryReader(fsShapeFile, Encoding.Unicode);
            brShapeFile.BaseStream.Seek(0, 0);
            //读取四个字节,检查文件头
            if (brShapeFile.ReadInt32() != 170328064)
            {
                //文件真实的编码是9994,
                //170328064的16进制为0x0a27,交换字节顺序后就是0x270a,十进制就是9994了
                throw (new ApplicationException("无效的Shapefile文件 (.shp)"));
            }
            //五个没有被使用的int32整数
            brShapeFile.BaseStream.Seek(24, 0);
            //获取文件长度,包括文件头
            _FileSize = 2 * SwapByteOrder(brShapeFile.ReadInt32());
            //读取几何类型
            _ShapeType = (ShapeTypeEnum)brShapeFile.ReadInt32();
            //读取数据的外包矩形
            brShapeFile.BaseStream.Seek(36, 0);
            _Envelope = new BoundingBox(brShapeFile.ReadDouble(), brShapeFile.ReadDouble(), brShapeFile.ReadDouble(),
                                        brShapeFile.ReadDouble());

            //通过.shp文件获取数据条数
            // 跳过文件头读取
            brShapeFile.BaseStream.Seek(100, 0);
            // 几何数据记录开始位置
            long offset = 100;

            //遍历数据建立功能包含在数据文件的数量
            while (offset < _FileSize)
            {
                ++_FeatureCount;

                brShapeFile.BaseStream.Seek(offset + 4, 0); //跳过长度
                int data_length = 2 * SwapByteOrder(brShapeFile.ReadInt32());

                if ((offset + data_length) > _FileSize)
                {
                    --_FeatureCount;
                }

                offset += data_length; // 添加记录数据长度
                offset += 8;           //  +添加每条数据记录头的大小
            }
            _OffsetOfRecord = new int[_FeatureCount];
            //brShapeFile.Close();
            //fsShapeFile.Close();
        }
Beispiel #6
0
        public IShape GetShape(ShapeTypeEnum type)
        {
            switch (type)
            {
            case ShapeTypeEnum.Circle:
                return(new Circle());

            case ShapeTypeEnum.Square:
                return(new Square());

            case ShapeTypeEnum.Rectangle:
                return(new Rectangle());

            default:
                return(null);
            }
        }
        public Shape CreateShape(ShapeTypeEnum shapeType, double shapeWidth)
        {
            switch (shapeType)
            {
            case ShapeTypeEnum.SQUARE:
                return(new Square(shapeWidth));

            case ShapeTypeEnum.CIRCLE:
                return(new Circle(shapeWidth));

            case ShapeTypeEnum.EQUILATERAL_TRIANGLE:
                return(new EquilateralTriangle(shapeWidth));

            default:
                throw new ArgumentOutOfRangeException("ShapeType", "Unknown Shape Type");
            }
        }
Beispiel #8
0
        private void ShapeStyle_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rdShape = sender as RadioButton;

            if (rdShape == null || !rdShape.Checked)
            {
                return;
            }

            if (!int.TryParse((string)rdShape.Tag, out int tag))
            {
                return;
            }

            ShapeTypeEnum shapeType = (ShapeTypeEnum)tag;

            drawHandler.SetShape(shapeType);
        }
Beispiel #9
0
        /// <summary>
        /// 从.shp文件中读取并解析几何对象
        /// </summary>
        /// <param name="oid"></param>
        /// <returns></returns>
        private Geometry ReadGeometry(int oid)
        {
            brShapeFile.BaseStream.Seek(_OffsetOfRecord[oid] + 8, 0);
            ShapeTypeEnum type = (ShapeTypeEnum)brShapeFile.ReadInt32(); //Shape type

            if (type == ShapeTypeEnum.Null)
            {
                return(null);
            }
            if (type == ShapeTypeEnum.Point)
            {
                return(new Point(brShapeFile.ReadDouble(), brShapeFile.ReadDouble()));
            }
            else
            {
                throw (new ApplicationException("Shapefile 文件类型 " + _ShapeType.ToString() + " 不支持"));
            }
        }
Beispiel #10
0
 public void SetShape(ShapeTypeEnum shapeType) => ActiveShape = shapeType;