Exemple #1
0
        public void Add_Beyond_Max_Limits_To_Max()
        {
            Extents extents = new Extents();

            Assert.That(extents.MaxLatitude, Is.EqualTo(-90));
            Assert.That(extents.MinLatitude, Is.EqualTo(90));
            Assert.That(extents.MaxLongitude, Is.EqualTo(-180));
            Assert.That(extents.MinLongitude, Is.EqualTo(180));

            extents.Add(new Coordinate(300, 10));
            Assert.That(extents.MaxLatitude, Is.EqualTo(90));
            Assert.That(extents.MinLatitude, Is.EqualTo(90));
            Assert.That(extents.MaxLongitude, Is.EqualTo(10));
            Assert.That(extents.MinLongitude, Is.EqualTo(10));

            extents.Add(new Coordinate(10, 300));
            Assert.That(extents.MaxLatitude, Is.EqualTo(90));
            Assert.That(extents.MinLatitude, Is.EqualTo(10));
            Assert.That(extents.MaxLongitude, Is.EqualTo(180));
            Assert.That(extents.MinLongitude, Is.EqualTo(10));

            extents.Add(new Coordinate(-10, -300));
            Assert.That(extents.MaxLatitude, Is.EqualTo(90));
            Assert.That(extents.MinLatitude, Is.EqualTo(-10));
            Assert.That(extents.MaxLongitude, Is.EqualTo(180));
            Assert.That(extents.MinLongitude, Is.EqualTo(-180));

            extents.Add(new Coordinate(-300, -10));
            Assert.That(extents.MaxLatitude, Is.EqualTo(90));
            Assert.That(extents.MinLatitude, Is.EqualTo(-90));
            Assert.That(extents.MaxLongitude, Is.EqualTo(180));
            Assert.That(extents.MinLongitude, Is.EqualTo(-180));
        }
Exemple #2
0
        public Laboratory(List <Region> regions, int metalThickeness)
        {
            Regions        = regions;
            MetalThickness = metalThickeness;

            var minX = int.MaxValue;
            var maxX = int.MinValue;
            var minY = int.MaxValue;
            var maxY = int.MinValue;

            foreach (var region in regions)
            {
                if (region.BottomLeftCorner.X < minX)
                {
                    minX = region.BottomLeftCorner.X;
                }
                if (region.TopRightCorner.X > maxX)
                {
                    maxX = region.TopRightCorner.X;
                }
                if (region.TopRightCorner.Y > maxY)
                {
                    maxY = region.TopRightCorner.Y;
                }
                if (region.BottomLeftCorner.Y < minY)
                {
                    minY = region.BottomLeftCorner.Y;
                }
            }

            Extents.Add(new IntVector2(minX, maxY));
            Extents.Add(new IntVector2(maxX, maxY));
            Extents.Add(new IntVector2(maxX, minY));
            Extents.Add(new IntVector2(minX, minY));
        }
Exemple #3
0
        public void IsWithinExtents_Within_Extents_Returns_True()
        {
            Extents extents = new Extents();

            extents.Add(StarRegion);

            Assert.IsTrue(extents.IsWithinExtents(new Coordinate(25, 10)));
        }
        public void IsWithinExtents_Within_Extents_Returns_True()
        {
            Extents extents = new Extents();

            extents.Add(StarGlobalPoles);

            Assert.IsTrue(extents.IsWithinExtents(25, 10));
        }
Exemple #5
0
        public MonsterDen(IntVector2 centerpoint, int radius)
        {
            Centerpoint = centerpoint;
            Radius      = radius;

            Extents.Add(new IntVector2(Centerpoint.X - Radius, Centerpoint.Y));
            Extents.Add(new IntVector2(Centerpoint.X + Radius, Centerpoint.Y));
            Extents.Add(new IntVector2(Centerpoint.X, Centerpoint.Y + Radius));
        }
Exemple #6
0
        public void IsWithinExtents_Not_Within_Extents_Returns_False()
        {
            Extents extents = new Extents();

            extents.Add(StarRegion);

            Assert.IsFalse(extents.IsWithinExtents(new Coordinate(25, 100)));   // Partially within extents
            Assert.IsFalse(extents.IsWithinExtents(new Coordinate(95, 10)));    // Partial within extents
            Assert.IsFalse(extents.IsWithinExtents(new Coordinate(95, 100)));   // Totally outside extents
        }
Exemple #7
0
        public Room(IntVector2 bottomLeftCorner, IntVector2 topRightCorner)
        {
            BottomLeftCorner = bottomLeftCorner;
            TopRightCorner   = topRightCorner;

            Extents.Add(BottomLeftCorner);
            Extents.Add(new IntVector2(BottomLeftCorner.X, TopRightCorner.Y));
            Extents.Add(TopRightCorner);
            Extents.Add(new IntVector2(TopRightCorner.X, BottomLeftCorner.Y));
        }
        public void IsWithinExtents_Not_Within_Extents_Returns_False()
        {
            Extents extents = new Extents();

            extents.Add(StarGlobalPoles);

            Assert.IsFalse(extents.IsWithinExtents(25, 100));   // Partially within extents
            Assert.IsFalse(extents.IsWithinExtents(95, 10));    // Partial within extents
            Assert.IsFalse(extents.IsWithinExtents(95, 100));   // Totally within extents
        }
Exemple #9
0
        public void Add_Extents()
        {
            Extents extents = new Extents();

            Assert.That(extents.MaxLatitude, Is.EqualTo(-90));
            Assert.That(extents.MinLatitude, Is.EqualTo(90));
            Assert.That(extents.MaxLongitude, Is.EqualTo(-180));
            Assert.That(extents.MinLongitude, Is.EqualTo(180));

            extents.Add(StarRegion);
            Assert.That(extents.MaxLatitude, Is.EqualTo(89));
            Assert.That(extents.MinLatitude, Is.EqualTo(-90));
            Assert.That(extents.MaxLongitude, Is.EqualTo(90));
            Assert.That(extents.MinLongitude, Is.EqualTo(-90));

            Extents newExtents = new Extents();

            newExtents.Add(extents);
            Assert.That(newExtents.MaxLatitude, Is.EqualTo(89));
            Assert.That(newExtents.MinLatitude, Is.EqualTo(-90));
            Assert.That(newExtents.MaxLongitude, Is.EqualTo(90));
            Assert.That(newExtents.MinLongitude, Is.EqualTo(-90));

            Extents wideExtents = new Extents();

            wideExtents.Add(new Coordinate(45, 120));
            newExtents.Add(wideExtents);
            Assert.That(newExtents.MaxLatitude, Is.EqualTo(89));
            Assert.That(newExtents.MinLatitude, Is.EqualTo(-90));
            Assert.That(newExtents.MaxLongitude, Is.EqualTo(120));
            Assert.That(newExtents.MinLongitude, Is.EqualTo(-90));

            Extents wideNegativeExtents = new Extents();

            wideNegativeExtents.Add(new Coordinate(-35, -140));
            newExtents.Add(wideNegativeExtents);
            Assert.That(newExtents.MaxLatitude, Is.EqualTo(89));
            Assert.That(newExtents.MinLatitude, Is.EqualTo(-90));
            Assert.That(newExtents.MaxLongitude, Is.EqualTo(120));
            Assert.That(newExtents.MinLongitude, Is.EqualTo(-140));
        }
        public void Add_Extents()
        {
            Extents extents = new Extents();

            Assert.That(extents.MaxLatitude, Is.EqualTo(-90));
            Assert.That(extents.MinLatitude, Is.EqualTo(90));
            Assert.That(extents.MaxLongitude, Is.EqualTo(-180));
            Assert.That(extents.MinLongitude, Is.EqualTo(180));

            extents.Add(StarGlobalPoles);
            Assert.That(extents.MaxLatitude, Is.EqualTo(90));
            Assert.That(extents.MinLatitude, Is.EqualTo(-90));
            Assert.That(extents.MaxLongitude, Is.EqualTo(90));
            Assert.That(extents.MinLongitude, Is.EqualTo(-90));

            Extents newExtents = new Extents();

            newExtents.Add(extents);
            Assert.That(newExtents.MaxLatitude, Is.EqualTo(90));
            Assert.That(newExtents.MinLatitude, Is.EqualTo(-90));
            Assert.That(newExtents.MaxLongitude, Is.EqualTo(90));
            Assert.That(newExtents.MinLongitude, Is.EqualTo(-90));

            Extents wideExtents = new Extents();

            wideExtents.Add(new Vector(45, 120));
            newExtents.Add(wideExtents);
            Assert.That(newExtents.MaxLatitude, Is.EqualTo(90));
            Assert.That(newExtents.MinLatitude, Is.EqualTo(-90));
            Assert.That(newExtents.MaxLongitude, Is.EqualTo(120));
            Assert.That(newExtents.MinLongitude, Is.EqualTo(-90));

            Extents wideNegativeExtents = new Extents();

            wideNegativeExtents.Add(new Vector(-35, -140));
            newExtents.Add(wideNegativeExtents);
            Assert.That(newExtents.MaxLatitude, Is.EqualTo(90));
            Assert.That(newExtents.MinLatitude, Is.EqualTo(-90));
            Assert.That(newExtents.MaxLongitude, Is.EqualTo(120));
            Assert.That(newExtents.MinLongitude, Is.EqualTo(-140));
        }
        public void Add_IEnumerable()
        {
            Extents extents = new Extents();

            Assert.That(extents.MaxLatitude, Is.EqualTo(-90));
            Assert.That(extents.MinLatitude, Is.EqualTo(90));
            Assert.That(extents.MaxLongitude, Is.EqualTo(-180));
            Assert.That(extents.MinLongitude, Is.EqualTo(180));

            extents.Add(StarGlobalPoles);
            Assert.That(extents.MaxLatitude, Is.EqualTo(90));
            Assert.That(extents.MinLatitude, Is.EqualTo(-90));
            Assert.That(extents.MaxLongitude, Is.EqualTo(90));
            Assert.That(extents.MinLongitude, Is.EqualTo(-90));
        }
        private void Load(Stream source)
        {
            if (source.Length - source.Position > MaxSize)
            {
                throw new IOException(string.Format(CultureInfo.InvariantCulture,
                                                    "Invalid VMDK descriptor file, more than {0} bytes in length", MaxSize));
            }

            StreamReader reader = new StreamReader(source);
            string       line   = reader.ReadLine();

            while (line != null)
            {
                line = line.Trim('\0');

                int commentPos = line.IndexOf('#');
                if (commentPos >= 0)
                {
                    line = line.Substring(0, commentPos);
                }

                if (line.Length > 0)
                {
                    if (line.StartsWith("RW", StringComparison.Ordinal) ||
                        line.StartsWith("RDONLY", StringComparison.Ordinal) ||
                        line.StartsWith("NOACCESS", StringComparison.Ordinal))
                    {
                        Extents.Add(ExtentDescriptor.Parse(line));
                    }
                    else
                    {
                        DescriptorFileEntry entry = DescriptorFileEntry.Parse(line);
                        if (entry.Key.StartsWith("ddb.", StringComparison.Ordinal))
                        {
                            _diskDataBase.Add(entry);
                        }
                        else
                        {
                            _header.Add(entry);
                        }
                    }
                }

                line = reader.ReadLine();
            }
        }
Exemple #13
0
        public void Add_Points()
        {
            Extents extents = new Extents();

            Assert.That(extents.MaxLatitude, Is.EqualTo(-90));
            Assert.That(extents.MinLatitude, Is.EqualTo(90));
            Assert.That(extents.MaxLongitude, Is.EqualTo(-180));
            Assert.That(extents.MinLongitude, Is.EqualTo(180));

            // Pt 1
            int point = 1;

            extents.Add(new Coordinate(StarRegion[point - 1].Latitude, StarRegion[point - 1].Longitude));
            Assert.That(extents.MaxLatitude, Is.EqualTo(89));
            Assert.That(extents.MinLatitude, Is.EqualTo(89));
            Assert.That(extents.MaxLongitude, Is.EqualTo(0));
            Assert.That(extents.MinLongitude, Is.EqualTo(0));

            // Pt 2
            point = 2;
            extents.Add(new Coordinate(StarRegion[point - 1].Latitude, StarRegion[point - 1].Longitude));
            Assert.That(extents.MaxLatitude, Is.EqualTo(89));
            Assert.That(extents.MinLatitude, Is.EqualTo(24));
            Assert.That(extents.MaxLongitude, Is.EqualTo(20));
            Assert.That(extents.MinLongitude, Is.EqualTo(0));

            // Pt 3
            point = 3;
            extents.Add(new Coordinate(StarRegion[point - 1].Latitude, StarRegion[point - 1].Longitude));
            Assert.That(extents.MaxLatitude, Is.EqualTo(89));
            Assert.That(extents.MinLatitude, Is.EqualTo(24));
            Assert.That(extents.MaxLongitude, Is.EqualTo(90));
            Assert.That(extents.MinLongitude, Is.EqualTo(0));

            // Pt 4
            point = 4;
            extents.Add(new Coordinate(StarRegion[point - 1].Latitude, StarRegion[point - 1].Longitude));
            Assert.That(extents.MaxLatitude, Is.EqualTo(89));
            Assert.That(extents.MinLatitude, Is.EqualTo(-20));
            Assert.That(extents.MaxLongitude, Is.EqualTo(90));
            Assert.That(extents.MinLongitude, Is.EqualTo(0));

            // Pt 5
            point = 5;
            extents.Add(new Coordinate(StarRegion[0].Latitude, StarRegion[0].Longitude));
            extents.Add(new Coordinate(StarRegion[point - 1].Latitude, StarRegion[point - 1].Longitude));
            Assert.That(extents.MaxLatitude, Is.EqualTo(89));
            Assert.That(extents.MinLatitude, Is.EqualTo(-90));
            Assert.That(extents.MaxLongitude, Is.EqualTo(90));
            Assert.That(extents.MinLongitude, Is.EqualTo(0));

            // Pt 6
            point = 6;
            extents.Add(new Coordinate(StarRegion[point - 1].Latitude, StarRegion[point - 1].Longitude));
            Assert.That(extents.MaxLatitude, Is.EqualTo(89));
            Assert.That(extents.MinLatitude, Is.EqualTo(-90));
            Assert.That(extents.MaxLongitude, Is.EqualTo(90));
            Assert.That(extents.MinLongitude, Is.EqualTo(0));

            // Pt 7
            point = 7;
            extents.Add(new Coordinate(StarRegion[point - 1].Latitude, StarRegion[point - 1].Longitude));
            Assert.That(extents.MaxLatitude, Is.EqualTo(89));
            Assert.That(extents.MinLatitude, Is.EqualTo(-90));
            Assert.That(extents.MaxLongitude, Is.EqualTo(90));
            Assert.That(extents.MinLongitude, Is.EqualTo(-60));

            // Pt 8
            point = 8;
            extents.Add(new Coordinate(StarRegion[point - 1].Latitude, StarRegion[point - 1].Longitude));
            Assert.That(extents.MaxLatitude, Is.EqualTo(89));
            Assert.That(extents.MinLatitude, Is.EqualTo(-90));
            Assert.That(extents.MaxLongitude, Is.EqualTo(90));
            Assert.That(extents.MinLongitude, Is.EqualTo(-60));

            // Pt 9
            point = 9;
            extents.Add(new Coordinate(StarRegion[point - 1].Latitude, StarRegion[point - 1].Longitude));
            Assert.That(extents.MaxLatitude, Is.EqualTo(89));
            Assert.That(extents.MinLatitude, Is.EqualTo(-90));
            Assert.That(extents.MaxLongitude, Is.EqualTo(90));
            Assert.That(extents.MinLongitude, Is.EqualTo(-90));

            // Pt 10
            point = 10;
            extents.Add(new Coordinate(StarRegion[point - 1].Latitude, StarRegion[point - 1].Longitude));
            Assert.That(extents.MaxLatitude, Is.EqualTo(89));
            Assert.That(extents.MinLatitude, Is.EqualTo(-90));
            Assert.That(extents.MaxLongitude, Is.EqualTo(90));
            Assert.That(extents.MinLongitude, Is.EqualTo(-90));
        }
Exemple #14
0
        public Geoset1300(BinaryReader br)
        {
            TotalSize = br.ReadUInt32();
            long end = TotalSize + br.BaseStream.Position;

            //Vertices
            if (br.HasTag("VRTX"))
            {
                NrOfVertices = br.ReadUInt32();
                for (int i = 0; i < NrOfVertices; i++)
                {
                    Vertices.Add(new CVector3(br));
                }
            }

            //Normals
            if (br.HasTag("NRMS"))
            {
                NrOfNormals = br.ReadUInt32();
                for (int i = 0; i < NrOfNormals; i++)
                {
                    Normals.Add(new CVector3(br));
                }
            }

            //TexCoords
            if (br.HasTag("UVAS"))
            {
                NrOfTexCoords = br.ReadUInt32();                 //Amount of groups
                for (int i = 0; i < NrOfNormals * NrOfTexCoords; i++)
                {
                    TexCoords.Add(new CVector2(br));
                }
            }

            //Face Group Type
            if (br.HasTag("PTYP"))
            {
                NrOfFaceTypeGroups = br.ReadUInt32();
                FaceTypes.AddRange(br.ReadBytes((int)NrOfFaceTypeGroups));
            }

            //Face Groups
            if (br.HasTag("PCNT"))
            {
                NrOfFaceGroups = br.ReadUInt32();
                for (int i = 0; i < NrOfFaceGroups; i++)
                {
                    FaceGroups.Add(br.ReadUInt32());
                }
            }

            //Indexes
            if (br.HasTag("PVTX"))
            {
                NrOfFaceVertices = br.ReadUInt32();
                for (int i = 0; i < NrOfFaceVertices / 3; i++)
                {
                    FaceVertices.Add(new CVertex(br));
                }
            }

            //Vertex Groups
            if (br.HasTag("GNDX"))
            {
                NrOfVertexGroupIndices = br.ReadUInt32();
                VertexGroupIndices.AddRange(br.ReadBytes((int)NrOfVertexGroupIndices));
            }

            //Matrix Groups
            if (br.HasTag("MTGC"))
            {
                NrOfMatrixGroups = br.ReadUInt32();
                for (int i = 0; i < NrOfMatrixGroups; i++)
                {
                    MatrixGroups.Add(br.ReadUInt32());
                }
            }

            //Matrix Indexes
            if (br.HasTag("MATS"))
            {
                NrOfMatrixIndexes = br.ReadUInt32();
                for (int i = 0; i < NrOfMatrixIndexes; i++)
                {
                    MatrixIndexes.Add(br.ReadUInt32());
                }
            }

            //Bone Indexes
            if (br.HasTag("BIDX"))
            {
                NrOfBoneIndexes = br.ReadUInt32();
                for (int i = 0; i < NrOfBoneIndexes; i++)
                {
                    BoneIndexes.Add(br.ReadUInt32());
                }
            }

            //Bone Weights
            if (br.HasTag("BWGT"))
            {
                NrOfBoneWeights = br.ReadUInt32();
                for (int i = 0; i < NrOfBoneWeights; i++)
                {
                    BoneWeights.Add(br.ReadUInt32());
                }
            }

            MaterialId     = br.ReadUInt32();
            SelectionGroup = br.ReadUInt32();
            Unselectable   = br.ReadUInt32() == 1;
            Bounds         = new CExtent(br);

            //Extents
            NrOfExtents = br.ReadUInt32();
            for (int i = 0; i < NrOfExtents; i++)
            {
                Extents.Add(new CExtent(br));
            }

            //Grouped Vertices
            for (int i = 0; i < NrOfVertices; i++)
            {
                if (!GroupedVertices.ContainsKey(VertexGroupIndices[i]))
                {
                    GroupedVertices.Add(VertexGroupIndices[i], new List <CVector3>());
                }

                GroupedVertices[VertexGroupIndices[i]].Add(Vertices[i]);
            }
        }
 public void AddExtent(ExtentPart fromPart)
 {
     Extents.Add(fromPart);
 }