Пример #1
0
        public RegionEventType(pActiveRegionType r)
            : base(r.ID)
        {


            //Convert to the form needed by the convexity tester
            List<GeometricPointType> gList = new List<GeometricPointType>();
            for (int i = 0; i < r.Vertices.Count; i++)
            {
                gList.Add(new GeometricPointType(r.Vertices[i].X, r.Vertices[i].Y));
            }
            if (!ConvexTest.IsConvex(gList))
            {
                throw (new ApplicationException("Region " + r.ID + " is not convex"));
            }
            vertices = new List<PointType>();
            for (int i = 0; i < gList.Count; i++)
            {
                vertices.Add(new PointType(gList[i]));
            }

            start = r.Start;
            end = r.End;
            speedMultiplier = r.SpeedMultiplier;
            blocksMovement = r.BlocksMovement;
            sensorsBlocked = new List<string>(); //r.SensorsBlocked;
            obstructedViewImage = r.ObstructedViewImage;
            obstructionOpacity = r.ObstructionOpacity;
            for (int i = 0; i < r.SensorsBlocked.Count; i++)
            {
                sensorsBlocked.Add(r.SensorsBlocked[i]);
            }
            isVisible = r.IsVisible;
            isActive = r.IsActive;
            isDynamicRegion = r.IsDynamicRegion;
            if (r.ReferencePoint == null)
                referencePoint = new PointType(new pPointType(0, 0));
            else
                referencePoint = new PointType(new GeometricPointType(r.ReferencePoint.X,r.ReferencePoint.Y));
     
            
            this.chroma = Color.FromName(r.Color).ToArgb();

        }
Пример #2
0
        public override pActiveRegionType pGetActiveRegion()
        {
            string id = "Unknown Active Region";
            pActiveRegionType region;
            try
            {
                reader.Read(); // bypass 'xxxRegion'
                id = pGetString();
                region = new pActiveRegionType(id);
                while ("Vertex" == reader.Name)
                {
                    region.Add(pGetPoint());
                }
                if (3 > region.Vertices.Count)
                {
                    throw new ApplicationException("Found vertex list for region "
                        + id + " with fewer than three vertices.");
                }
                region.Start = 0.0;
                if ("Start" == reader.Name)
                    region.Start = pGetDouble();
                region.End = 0.0;
                if ("End" == reader.Name)
                    region.End = pGetDouble();
                region.SpeedMultiplier = 1;
                if ("SpeedMultiplier" == reader.Name) region.SpeedMultiplier = pGetDouble();
                region.BlocksMovement = false;
                if ("BlocksMovement" == reader.Name) region.BlocksMovement = pGetBoolean();
                if ("SensorsBlocked" == reader.Name)
                {
                    region.Add(pGetStringList(commaRegex));
                }
                if ("IsVisible" == reader.Name)
                    region.IsVisible = pGetBoolean();
                if ("IsActive" == reader.Name)
                    region.IsActive = pGetBoolean();
                if ("Color" == reader.Name)
                    region.Color = pGetColor();
                if ("ObstructedViewImage" == reader.Name)
                    region.ObstructedViewImage = pGetString();
                if ("ObstructionOpacity" == reader.Name)
                    region.ObstructionOpacity = pGetDouble();
                reader.ReadEndElement();
            }
            catch (System.Exception e)
            {
                throw new ApplicationException("Error reading Active Region with id=" +
                    id + ": ", e);
            }

            return region;
        }