public bool InitializeContributing(bool parity, PolygonType type)
 {
     if (type == PolygonType.SUBJECT)
     {
         if (parity == true)
         {
             return(m_sParityForContribution);
         }
         else
         {
             return(!m_sParityForContribution);
         }
     }
     else
     {
         if (parity == true)
         {
             return(m_cParityForContribution);
         }
         else
         {
             return(!m_cParityForContribution);
         }
     }
 }
Esempio n. 2
0
        public static PolygonType ToGmlPolygon(this Polygon polygon)
        {
            PolygonType gmlPolygon = new PolygonType();

            if (polygon.Coordinates.Count > 0)
            {
                gmlPolygon.exterior = new AbstractRingPropertyType();
                if (!polygon.Coordinates.Any(ls => !ls.IsClosed()))
                {
                    polygon = ClosePolygon(polygon);
                }
                gmlPolygon.exterior.Item = ToGmlLinearRing(polygon.Coordinates[0]);
                if (polygon.Coordinates.Count > 1)
                {
                    var interiors = new List <AbstractRingPropertyType>();
                    foreach (var lineString in polygon.Coordinates.Take(1))
                    {
                        var interior = new AbstractRingPropertyType();
                        interior.Item = ToGmlLinearRing(lineString);
                        interiors.Add(interior);
                    }
                    gmlPolygon.interior = interiors.ToArray();
                }
            }

            return(gmlPolygon);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            //Point p1 = new Point() { X = 0, Y = 1 };
            //Point p2 = new Point() { X = 1, Y = 0 };
            Point p3 = new Point() { X = 0, Y = -1 };
            Point p4 = new Point() { X = 1, Y = -1 };
            Point p5 = new Point() { X = 2, Y = -1 };
            //Point p6 = new Point() { X = 2, Y = 0 };
            //Point p7 = new Point() { X = 2, Y = 1 };


            //Point p1 = new Point() { X = 0, Y = 1 };
            //Point p2 = new Point() { X = 1, Y = 0 };
            //Point p3 = new Point() { X = 0, Y = -1 };
            //Point p4 = new Point() { X = -1, Y = -1 };
            //Point p5 = new Point() { X = -2, Y = -1 };
            //Point p6 = new Point() { X = -2, Y = 0 };
            //Point p7 = new Point() { X = -2, Y = 1 };
            List<Point> points = new List<Point>();

            //double result = cal(p3, p2, p1);
            //points.Add(p1);
            //points.Add(p2);
            points.Add(p3);
            points.Add(p4);
            points.Add(p5);
            //points.Add(p6);
            //points.Add(p7);
            ClockDirection vDirection = Polygon.CalculateClockDirection(points, false);
            PolygonType type = Polygon.CalculatePolygonType(points, false);
            bool flag = Polygon.IsPolyClockwise(points);

        }
Esempio n. 4
0
        void ProcessSegment(Segment segment, PolygonType polygonType)
        {
            if (Misc.PointEquals(segment.start, segment.end))
            {
                return;
            }
            SweepEvent e1 = new SweepEvent(segment.start, true, polygonType);
            SweepEvent e2 = new SweepEvent(segment.end, true, polygonType, e1);

            e1.otherSE = e2;

            if (e1.p.x < e2.p.x)
            {
                e2.isLeft = false;
            }
            else if (e1.p.x > e2.p.x)
            {
                e1.isLeft = false;
            }
            else if (e1.p.y < e2.p.y)                 // the segment isLeft vertical. The bottom endpoint isLeft the isLeft endpoint
            {
                e2.isLeft = false;
            }
            else
            {
                e1.isLeft = false;
            }

            // Pushing it so the que is sorted from left to right, with object on the left
            // having the highest priority.
            eventQueue.Enqueue(e1);
            eventQueue.Enqueue(e2);
        }
Esempio n. 5
0
        public static PolygonType ToGmlPolygon(this Polygon poly)
        {
            Polygon     polygon    = poly;
            PolygonType gmlPolygon = new PolygonType();

            if (polygon.Coordinates.Count > 0)
            {
                var exterior = new AbstractRingPropertyType();
                gmlPolygon.Item            = exterior;
                gmlPolygon.ItemElementName = ItemChoiceType5.exterior;
                if (!polygon.Coordinates.Any(ls => !ls.IsClosed()))
                {
                    polygon = ClosePolygon(polygon);
                }

                exterior.Item = ToGmlLinearRing(polygon.Coordinates[0]);
                if (polygon.Coordinates.Count > 1)
                {
                    var interiors = new List <AbstractRingPropertyType>();
                    foreach (var lineString in polygon.Coordinates.Skip(1))
                    {
                        var interior = new AbstractRingPropertyType();
                        interior.Item = ToGmlLinearRing(lineString);
                        interiors.Add(interior);
                    }
                    gmlPolygon.Items1            = interiors.ToArray();
                    gmlPolygon.Items1ElementName = interiors.Select <AbstractRingPropertyType, Items1ChoiceType3>(int1 => Items1ChoiceType3.interior).ToArray();
                }
            }

            return(gmlPolygon);
        }
 public bool InitializeContributing(bool parity, PolygonType type)
 {
     if (type == PolygonType.SUBJECT)
     {
         if (parity == true)
         {
             return m_sParityForContribution;
         }
         else
         {
             return !m_sParityForContribution;
         }
     }
     else
     {
         if (parity == true)
         {
             return m_cParityForContribution;
         }
         else
         {
             return !m_cParityForContribution;
         }
     }
 }
Esempio n. 7
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = StartUtc.GetHashCode();
         hashCode = (hashCode * 397) ^ EndUtc.GetHashCode();
         hashCode = (hashCode * 397) ^ (DateRangeType != null ? DateRangeType.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (DesignUid != null ? DesignUid.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (DesignFileName != null ? DesignFileName.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (ContributingMachines != null ? ContributingMachines.GetListHashCode() : 397);
         hashCode = (hashCode * 397) ^ (OnMachineDesignId != null ? OnMachineDesignId.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (OnMachineDesignName != null ? OnMachineDesignName.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (ElevationType != null ? ElevationType.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (VibeStateOn != null ? VibeStateOn.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (PolygonUid != null ? PolygonUid.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (PolygonName != null ? PolygonName.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (PolygonLL != null ? PolygonLL.GetListHashCode() : 397);
         hashCode = (hashCode * 397) ^ (PolygonType != null ? PolygonType.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (ForwardDirection != null ? ForwardDirection.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (LayerNumber != null ? LayerNumber.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (AlignmentUid != null ? AlignmentUid.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (AlignmentFileName != null ? AlignmentFileName.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (StartStation != null ? StartStation.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (EndStation != null ? EndStation.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (LeftOffset != null ? LeftOffset.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (RightOffset != null ? RightOffset.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (AsAtDate != null ? AsAtDate.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (AutomaticsType != null ? AutomaticsType.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (TemperatureRangeMin != null ? TemperatureRangeMin.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (TemperatureRangeMax != null ? TemperatureRangeMax.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (PassCountRangeMin != null ? PassCountRangeMin.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (PassCountRangeMax != null ? PassCountRangeMax.GetHashCode() : 397);
         return(hashCode);
     }
 }
Esempio n. 8
0
 public Nominatim(FormatType format, PolygonType polygon, AddressDetailsType addressDetail)
 {
     _format        = format;
     _polygon       = polygon;
     _addressDetail = addressDetail;
     _search        = _searchUrl + "format=" + format.ToString() + "&polygon=" + (int)polygon + "&addressdetails=" + (int)addressDetail + "&q=";
 }
Esempio n. 9
0
        public static PolygonType ToGmlPolygon(this Polygon polygon)
        {
            PolygonType gmlPolygon = new PolygonType();

            if (polygon.LineStrings.Count > 0)
            {
                gmlPolygon.exterior = new AbstractRingPropertyType();
                if (!polygon.LineStrings[0].IsClosed())
                {
                    polygon.LineStrings[0].Positions.Add(polygon.LineStrings[0].Positions[0]);
                }
                gmlPolygon.exterior.Item = ToGmlLinearRing(polygon.LineStrings[0]);
                if (polygon.LineStrings.Count > 1)
                {
                    var interiors = new List <AbstractRingPropertyType>();
                    foreach (var lineString in polygon.LineStrings.Take(1))
                    {
                        var interior = new AbstractRingPropertyType();
                        if (!lineString.IsClosed())
                        {
                            lineString.Positions.Add(lineString.Positions[0]);
                        }
                        interior.Item = ToGmlLinearRing(lineString);
                        interiors.Add(interior);
                    }
                    gmlPolygon.interior = interiors.ToArray();
                }
            }

            return(gmlPolygon);
        }
Esempio n. 10
0
 public Polygon(PolygonType PolyType, Vector3[] Normals, Vector2[] TexCoords, Vector3[] Vertex)
 {
     this.PolyType = PolyType;
     this.Normals = Normals;
     this.TexCoords = TexCoords;
     this.Vertex = Vertex;
 }
Esempio n. 11
0
 public Polygon(PolygonType PolyType, Vector3[] Normals, Vector2[] TexCoords, Vector3[] Vertex)
 {
     this.PolyType  = PolyType;
     this.Normals   = Normals;
     this.TexCoords = TexCoords;
     this.Vertex    = Vertex;
 }
Esempio n. 12
0
        /// <summary>
        /// Creates the events for a segment.
        /// </summary>
        /// <param name="segment">A list consisting of two points defining an edge</param>
        /// <param name="polygonType"></param>
        /// <param name="list">The list to add the events to</param>
        private void CreateEvents(IList <Vector2D> segment, PolygonType polygonType,
                                  ICollection <SweepEvent> list)
        {
            var point1 = segment[0];
            var point2 = segment[1];

            var event1 = new SweepEvent(point1, false, null, polygonType);
            var event2 = new SweepEvent(point2, false, event1, polygonType);

            event1.OtherEvent = event2;

            if (point1.Equals(point2))
            {
                // 0-length segments are irrelevant for us since they will never result in intersections
                return;
            }

            // The segment could be ordered the wrong way around, so we need to set the IsStart field properly
            if (SweepEvent.CompareTo(event1, event2) > 0)
            {
                event2.IsStart = true;
            }
            else
            {
                event1.IsStart = true;
            }

            list.Add(event1);
            list.Add(event2);
        }
        public static PolygonType ToGmlPolygon(this Polygon polygon)
        {
            PolygonType gmlPolygon = new PolygonType();

            if (polygon.LineStrings.Count > 0)
            {
                var exterior = new AbstractRingPropertyType();
                gmlPolygon.Item            = exterior;
                gmlPolygon.ItemElementName = ItemChoiceType5.exterior;
                if (!polygon.LineStrings[0].IsClosed())
                {
                    polygon.LineStrings[0].Positions.Add(polygon.LineStrings[0].Positions[0]);
                }
                exterior.Item = ToGmlLinearRing(polygon.LineStrings[0]);
                if (polygon.LineStrings.Count > 1)
                {
                    var interiors = new List <AbstractRingPropertyType>();
                    foreach (var lineString in polygon.LineStrings.Take(1))
                    {
                        var interior = new AbstractRingPropertyType();
                        if (!lineString.IsClosed())
                        {
                            lineString.Positions.Add(lineString.Positions[0]);
                        }
                        exterior.Item = ToGmlLinearRing(lineString);
                        interiors.Add(interior);
                    }
                    gmlPolygon.Items1            = interiors.ToArray();
                    gmlPolygon.Items1ElementName = interiors.Select <AbstractRingPropertyType, Items1ChoiceType3>(int1 => Items1ChoiceType3.interior).ToArray();
                }
            }

            return(gmlPolygon);
        }
Esempio n. 14
0
        private void AddNewEvent(gEdge edge, PolygonType polType = PolygonType.None)
        {
            SweepEvent swStart = new SweepEvent(edge.StartVertex, edge)
            {
                Label = SweepEventLabel.Normal
            };
            SweepEvent swEnd = new SweepEvent(edge.EndVertex, edge)
            {
                Label = SweepEventLabel.Normal
            };

            swStart.Pair   = swEnd;
            swEnd.Pair     = swStart;
            swStart.IsLeft = swStart < swEnd;
            swEnd.IsLeft   = !swStart.IsLeft;

            if (polType != PolygonType.None)
            {
                swStart.polygonType = polType;
                swEnd.polygonType   = polType;
            }

            eventsList.AddItemSorted(swStart);
            eventsList.AddItemSorted(swEnd);
        }
Esempio n. 15
0
        private Geometry GetPolygon(MultiSurfaceType multi)
        {
            var p = new Polygon[multi.SurfaceMemberItems.Count];

            int npoly = 0;

            foreach (SurfacePropertyType member in multi.SurfaceMemberItems)
            {
                LinearRing  shell = null;
                PolygonType sur   = ExtractShellPolygon(ref shell, member);

                if (sur.Interior.Count == 0 && shell != null)
                {
                    p[npoly] = new Polygon(shell);
                }
                else
                {
                    var holes = new LinearRing[sur.Interior.Count];
                    ExtractInteriorPolygon(holes, sur);
                    p[npoly] = new Polygon(shell, holes);
                }

                npoly++;
            }

            return(new MultiPolygon(p));
        }
Esempio n. 16
0
 public PolygonDatabase(string fileName, PolygonType type, Resolution resolution, IDictionary <int, IPolygon <THeader, TPoint> > polygons)
 {
     this.FileName    = fileName;
     this.PolygonType = type;
     this.Resolution  = resolution;
     this.Polygons    = polygons;
 }
Esempio n. 17
0
 public SweepEvent(Point p, bool isLeft, PolygonType polygonType, SweepEvent otherSweepEvent, EdgeType edgeType)
 {
     this.p           = p;
     this.isLeft      = isLeft;
     this.polygonType = polygonType;
     this.otherSE     = otherSweepEvent;
     this.edgeType    = edgeType;
 }
 public Polygon(PolygonType PolyType, Vector3[] Vertex, Vector3[] Normals, Vector2[] TexCoords, Color[] Colors = null)
 {
     this.PolyType  = PolyType;
     this.Normals   = Normals;
     this.TexCoords = TexCoords;
     this.Vertex    = Vertex;
     this.Colors    = Colors;
 }
 public SweepEvent(Point p, bool isLeft, PolygonType polygonType, SweepEvent otherSweepEvent, EdgeType edgeType)
 {
     this.p = p;
     this.isLeft = isLeft;
     this.polygonType = polygonType;
     this.otherSE = otherSweepEvent;
     this.edgeType = edgeType;
 }
Esempio n. 20
0
 public static string Material(Category category, PolygonType pType)
 {
     if (category == Category.sticker)
     {
         return(Sticker_Material_Dir);
     }
     return(GetPath(MATERIAL_NAME, category, pType));
 }
Esempio n. 21
0
 private Kml2SqlConfig GetConfig(string tableName, PolygonType geoType)
 {
     return(new Kml2SqlConfig()
     {
         GeoType = geoType,
         TableName = _tablePrefix + tableName,
         FixPolygons = true,
     });
 }
Esempio n. 22
0
 // create a new polygon with a list of points (which won't change)
 public Polygon(List<PointF> ptlist)
 {
     PolyClose(ptlist);  // make sure the polygon is closed by duplicating the first point to the end, if necessary
     PtList = ptlist;
     PtListOpen = new List<PointF>(PtList);
     PtListOpen.RemoveAt(PtList.Count - 1);  // remove the last point, which is a duplicate of the first
     Area = PolyArea(PtList);
     Type = PolyType(PtList, Area);
 }
Esempio n. 23
0
 // create a new polygon with a list of points (which won't change)
 public Polygon(List <Vector2D> ptlist)
 {
     PolyClose(ptlist);  // make sure the polygon is closed by duplicating the first point to the end, if necessary
     PtList     = ptlist;
     PtListOpen = new List <Vector2D>(PtList);
     PtListOpen.RemoveAt(PtList.Count - 1);  // remove the last point, which is a duplicate of the first
     Area = PolyArea(PtList);
     Type = PolyType(PtList, Area);
 }
 // create a new polygon with a list of points (which won't change)
 public PolygonData(List<PointF> ptlist) {
     RemoveDoublePoints(ptlist); // make sure there are no two points with the same position
     PolyClose(ptlist);  // make sure the polygon is closed by duplicating the first point to the end, if necessary
     PtList = ptlist;
     PtListOpen = new List<PointF>(PtList);
     PtListOpen.RemoveAt(PtList.Count - 1);  // remove the last point, which is a duplicate of the first
     Area = PolyArea(PtList);
     Type = PolyType(PtList, Area);
 }
Esempio n. 25
0
    public static string Thumb(Category category, PolygonType pType)
    {
        string path = category == Category.sticker ? Sticker_Texture_Dir : GetPath(THUMB_NAME, category, pType);

#if BLOCK_EDITOR
        path = path.Replace("Assets/BlockRes", "block_thumbs");
#endif
        return(path);
    }
Esempio n. 26
0
 public override string ToString()
 {
     return(string.Format(
                "{0} ({1}) S:[{2} - {3}] ({4}) ({5})",
                Point, IsStart ? "left" : "right", Point, OtherEvent.Point,
                PolygonType.ToString().ToUpper(),
                EdgeType.ToString().ToUpper()
                ));
 }
Esempio n. 27
0
 private void Upload(string fileName, string tableName, PolygonType geoType)
 {
     using (SqlConnection connection = new SqlConnection(connectionString))
     {
         connection.Open();
         Kml2SqlConfig config   = GetConfig(tableName, geoType);
         var           uploader = new Uploader(fileName, config);
         uploader.Upload(connection, true);
     }
 }
Esempio n. 28
0
 // create a new polygon with a list of points (which won't change)
 public PolygonData(List <PointF> ptlist)
 {
     RemoveDoublePoints(ptlist); // make sure there are no two points with the same position
     PolyClose(ptlist);          // make sure the polygon is closed by duplicating the first point to the end, if necessary
     PtList     = ptlist;
     PtListOpen = new List <PointF>(PtList);
     PtListOpen.RemoveAt(PtList.Count - 1);  // remove the last point, which is a duplicate of the first
     Area = PolyArea(PtList);
     Type = PolyType(PtList, Area);
 }
Esempio n. 29
0
        public override int GetHashCode()
        {
            var hashCode = 1482638751;

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(TexturePath);

            hashCode = hashCode * -1521134295 + PolygonType.GetHashCode();
            hashCode = hashCode * -1521134295 + TransVal.GetHashCode();
            return(hashCode);
        }
Esempio n. 30
0
        /*****************************************
        *       To check vertices make a clock-wise polygon or
        *       count clockwise polygon
        *
        *       Restriction: the polygon is not self intersecting
        *       Ref: www.swin.edu.au/astronomy/pbourke/
        *       geometry/clockwise/index.html
        *****************************************/
        public PolygonDirection VerticesDirection()
        {
            int         nCount = 0, j = 0, k = 0;
            decimal     area      = 0;
            int         nVertices = m_aVertices.Length;
            PolygonType pType     = this.GetPolygonType();

            //Calculation Explanation:
            //http://local.wasp.uwa.edu.au/~pbourke/geometry/clockwise/index.html
            //Calculation for CONVEX (simple)
            if (pType == PolygonType.Convex)
            {
                double crossProduct = (m_aVertices[1].X - m_aVertices[0].X)
                                      * (m_aVertices[2].Y - m_aVertices[1].Y);
                crossProduct = crossProduct - (
                    (m_aVertices[1].Y - m_aVertices[0].Y)
                    * (m_aVertices[2].X - m_aVertices[1].X));

                if (crossProduct > 0)
                {
                    return(PolygonDirection.Count_Clockwise);
                }
                else if (crossProduct < 0)
                {
                    return(PolygonDirection.Clockwise);
                }
                else
                {
                    return(PolygonDirection.Unknown);
                }
            }
            else
            {
                for (int i = 0; i < nVertices - 1; i++)
                {
                    j = (i + 1);

                    area = area + Convert.ToDecimal((m_aVertices[i].X * m_aVertices[j].Y) - (m_aVertices[j].X * m_aVertices[i].Y));
                }
                area = area + Convert.ToDecimal((m_aVertices[nVertices - 1].X * m_aVertices[0].Y) - (m_aVertices[0].X * m_aVertices[nVertices - 1].Y));

                if (area > 0)
                {
                    return(PolygonDirection.Count_Clockwise);
                }
                else if (area < 0)
                {
                    return(PolygonDirection.Clockwise);
                }
                else
                {
                    return(PolygonDirection.Unknown);
                }
            }
        }
Esempio n. 31
0
        public SceneObjectBuilder StartSimpleSprite(float z, TextureInfo sprite, Color color)
        {
            this.applyPolygonData();

            this.currentPolygonType = PolygonType.Sprite;
            this.vertexData[z]      = new List <float>(SpriteHelpers.UnitRect(sprite));
            this.textureId          = sprite.Id;
            this.color = color;

            return(this);
        }
Esempio n. 32
0
        // create a new polygon with a list of points (which won't change)
        public Polygon(IEnumerable <Point2Dmm> pts)
        {
            var ptlist = new List <Point2Dmm>(pts);

            PolyClose(ptlist);  // make sure the polygon is closed by duplicating the first point to the end, if necessary
            PtList     = ptlist;
            PtListOpen = new List <Point2Dmm>(PtList);
            PtListOpen.RemoveAt(PtList.Count - 1);  // remove the last point, which is a duplicate of the first
            Area = PolyArea(PtList);
            Type = PolyType(PtList, Area);
        }
Esempio n. 33
0
        public SceneObjectBuilder StartSprite(float z, int textureId, Color color)
        {
            this.applyPolygonData();

            this.currentPolygonType = PolygonType.Sprite;
            this.vertexData[z]      = new List <float>();
            this.textureId          = textureId;
            this.color = color;

            return(this);
        }
    public static void CreatePrefabs(List <BlockDataGroup> blockDataGroups, PolygonType polygonType)
    {
        if (blockDataGroups == null || blockDataGroups.Count == 0)
        {
            return;
        }

        Category category = blockDataGroups[0].category;

        CreatePrefabsWithDataGroup(blockDataGroups, category, polygonType);
    }
Esempio n. 35
0
 public static string Fbx(Category category, PolygonType pType)
 {
     if (category == Category.sticker)
     {
         return(Sticker_Fbx_Dir);
     }
     if (category == Category.custom)
     {
         return(Custom_Fbx_Dir);
     }
     return(GetPath(FBX_NAME, category, pType));
 }
Esempio n. 36
0
        private static void ExtractInteriorPolygon(ILinearRing[] holes, PolygonType sur)
        {
            Collection<AbstractRingPropertyType> lin = sur.Interior as Collection<AbstractRingPropertyType>;
            int i = 0;
            foreach (AbstractRingPropertyType ringis in lin)
            {
                LinearRingType lii = ringis.Ring as LinearRingType;

                foreach (DirectPositionListType rings in lii.Items)
                {
                    List<Coordinate> lstCoor = ExtractCoordinates(rings);

                    holes[i]=new LinearRing(lstCoor);
                    i++;
                }

            }
        }
 public SweepEvent(Point p, bool isLeft, PolygonType polygonType, SweepEvent otherSweepEvent)
     : this(p,isLeft,polygonType,otherSweepEvent, EdgeType.NORMAL)
 {
 }
 public SweepEvent(Point p, bool isLeft, PolygonType polygonType)
     : this(p,isLeft,polygonType,null, EdgeType.NORMAL)
 {
 }
Esempio n. 39
0
 // -------------------------------------------------
 public RegPoly_Combi (PolygonType polytype, Point center, int rad, int apexes, double angleDegree, Color clr)
 {
     type = polytype;
     id = Auxi_Common .UniqueID;
     ptC = center;
     radius = Math .Max (Math .Abs (rad), minR);
     nApexes = Math .Max (Math .Abs (apexes), 3);
     angle = Auxi_Convert .DegreeToRadian (Auxi_Common .LimitedDegree (angleDegree));
     brush = new SolidBrush (clr);
 }
        void ProcessSegment(Segment segment, PolygonType polygonType)
        {
            if (Point.EqualsBoth(segment.start, segment.end)) return;
            SweepEvent e1 = new SweepEvent(segment.start, true, polygonType);
            SweepEvent e2 = new SweepEvent(segment.end, true, polygonType, e1);
            e1.otherSE = e2;

            if (e1.p.x < e2.p.x - Point.PRECISION ) {
                e2.isLeft = false;
            } else if (e1.p.x > e2.p.x + Point.PRECISION) {
                e1.isLeft = false;
            } else if (e1.p.y < e2.p.y - Point.PRECISION) { // the segment is vertical. The bottom endpoint is processed before the top endpoint
                e2.isLeft = false;
            } else {
                e1.isLeft = false;
            }

            // Pushing it so the que is sorted from left to right, with object on the left
            // having the highest priority.
            eventQueue.Enqueue(e1);
            eventQueue.Enqueue(e2);
        }
 private static int EncodeClassificationIndex(Side side1, PolygonType type1, Side side2, PolygonType type2)
 {
     return (((int)side1 + (int)type1) << 2) + (int)side2 + (int)type2;
 }
Esempio n. 42
0
        public static PolygonType ToGmlPolygon(this Polygon polygon)
        {
            PolygonType gmlPolygon = new PolygonType();
            if (polygon.LineStrings.Count > 0) {
                gmlPolygon.exterior = new AbstractRingPropertyType();
                if (!polygon.LineStrings[0].IsClosed()) {
                    polygon.LineStrings[0].Positions.Add(polygon.LineStrings[0].Positions[0]);
                }
                gmlPolygon.exterior.Item = ToGmlLinearRing(polygon.LineStrings[0]);
                if (polygon.LineStrings.Count > 1) {
                    var interiors = new List<AbstractRingPropertyType>();
                    foreach (var lineString in polygon.LineStrings.Take(1)) {
                        var interior = new AbstractRingPropertyType();
                        if (!lineString.IsClosed()) {
                            lineString.Positions.Add(lineString.Positions[0]);
                        }
                        interior.Item = ToGmlLinearRing(lineString);
                        interiors.Add(interior);
                    }
                    gmlPolygon.interior = interiors.ToArray();
                }
            }

            return gmlPolygon;
        }
Esempio n. 43
0
        public static PolygonType ToGmlPolygon(this Polygon polygon)
        {
            PolygonType gmlPolygon = new PolygonType();
            if (polygon.LineStrings.Count > 0) {
                var exterior = new AbstractRingPropertyType();
                gmlPolygon.Item = exterior;
                gmlPolygon.ItemElementName = ItemChoiceType5.exterior;
                if (!polygon.LineStrings[0].IsClosed()) {
                    polygon.LineStrings[0].Positions.Add(polygon.LineStrings[0].Positions[0]);
                }
                exterior.Item = ToGmlLinearRing(polygon.LineStrings[0]);
                if (polygon.LineStrings.Count > 1) {
                    var interiors = new List<AbstractRingPropertyType>();
                    foreach (var lineString in polygon.LineStrings.Take(1)) {
                        var interior = new AbstractRingPropertyType();
                        if (!lineString.IsClosed()) {
                            lineString.Positions.Add(lineString.Positions[0]);
                        }
                        exterior.Item = ToGmlLinearRing(lineString);
                        interiors.Add(interior);
                    }
                    gmlPolygon.Items1 = interiors.ToArray();
                    gmlPolygon.Items1ElementName = interiors.Select<AbstractRingPropertyType, Items1ChoiceType3>(int1 => Items1ChoiceType3.interior).ToArray();
                }
            }

            return gmlPolygon;
        }
 public IntersectionClassification ClassifyIntersection(Side side1, PolygonType type1, Side side2, PolygonType type2)
 {
     return m_classificationTable[EncodeClassificationIndex(side1, type1, side2, type2)];
 }
Esempio n. 45
0
        public uint surf_index; // surface index

        #endregion Fields

        #region Constructors

        public Polygon(PolygonType type, int flags = 0)
        {
            Type = type; Flags = flags;
        }
        private Edge PrepareActiveEdge(int boundPairIndex, ref MyPolygon.Vertex lowerVertex, ref MyPolygon.Vertex upperVertex, PolygonType polyType, Side side)
        {
            Edge newEdge = new Edge();
            newEdge.BoundPairIndex = boundPairIndex;
            newEdge.BoundPairSide = side;
            newEdge.Kind = polyType;
            if (polyType == PolygonType.CLIP)
            {
                newEdge.OutputSide = m_operation.ClipInvert ? OtherSide(side) : side;
            }
            else
            {
                newEdge.OutputSide = m_operation.SubjectInvert ? OtherSide(side) : side;
            }

            RecalculateActiveEdge(ref newEdge, ref lowerVertex, ref upperVertex, side);

            return newEdge;
        }
        private int SortInMinimum(ref Edge leftEdge, ref Edge rightEdge, PolygonType type)
        {
            bool parity = false;
            int i = 0;
            while (i < m_activeEdgeList.Count)
            {
                var edge = m_activeEdgeList[i];

                if (CompareEdges(ref leftEdge, ref edge) == -1) break;

                if (edge.Kind != type)
                {
                    parity = !parity;
                }

                ++i;
            }

            bool contributing = m_operation.InitializeContributing(parity, type);
            leftEdge.Contributing = contributing;
            rightEdge.Contributing = contributing;

            return i;
        }
Esempio n. 48
0
 // -------------------------------------------------        SelectdIndexChanged_comboPolygonType
 private void SelectdIndexChanged_comboPolygonType (object sender, EventArgs e)
 {
     if (bAfterInit)
     {
         polytype = (PolygonType) (sender as ComboBox) .SelectedIndex;
         NewSet ();
         RenewMover ();
         Invalidate ();
     }
 }
Esempio n. 49
0
        /// <summary>
        /// Find points on the left and right side.
        /// </summary>
        /// <param name="from">"From" polygon reference</param>
        /// <param name="to">"To" polygon reference</param>
        /// <param name="left">Point on the left side</param>
        /// <param name="right">Point on the right side</param>
        /// <param name="fromType">Polygon type of "From" polygon</param>
        /// <param name="toType">Polygon type of "To" polygon</param>
        /// <returns>True, if points found. False, if otherwise.</returns>
        public bool GetPortalPoints(PolyId from, PolyId to, ref Vector3 left, ref Vector3 right, ref PolygonType fromType, ref PolygonType toType)
        {
            MeshTile fromTile;
            Poly fromPoly;
            if (nav.TryGetTileAndPolyByRef(from, out fromTile, out fromPoly) == false)
                return false;
            fromType = fromPoly.PolyType;

            MeshTile toTile;
            Poly toPoly;
            if (nav.TryGetTileAndPolyByRef(to, out toTile, out toPoly) == false)
                return false;
            toType = toPoly.PolyType;

            return GetPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, ref left, ref right);
        }
        private void ProcessOldHorizontalEdges(float bottomY, ref float endX, ref PolygonType endType, ref int from, int to)
        {
            float currentEnd = endX;
            PolygonType currentType = endType;
            endX = float.PositiveInfinity;
            endType = PolygonType.SUBJECT;
            for (int j = from; j < to; ++j)
            {
                var horizontalEdge = m_activeEdgeList[j];
                Debug.Assert(horizontalEdge.TopY == bottomY && horizontalEdge.DXdy != 0.0f, "The edge was not a horizontal edge!?");

                float edgeEndX = horizontalEdge.BottomX + horizontalEdge.DXdy;
                if (edgeEndX == currentEnd && horizontalEdge.Kind == currentType)
                {
                    BoundPair pair = m_usedBoundPairs[horizontalEdge.BoundPairIndex];
                    MyPolygon.Vertex endVertex, newTopVertex;
                    pair.Parent.GetVertex(horizontalEdge.TopVertexIndex, out endVertex);
                    Vector3 newPosition = endVertex.Coord;

                    if (horizontalEdge.Contributing)
                    {
                        if (horizontalEdge.OutputSide == Side.LEFT)
                        {
                            horizontalEdge.AssociatedPolygon.Append(newPosition);
                        }
                        else
                        {
                            horizontalEdge.AssociatedPolygon.Prepend(newPosition);
                        }
                    }

                    if (horizontalEdge.BoundPairSide == Side.LEFT)
                    {
                        pair.Parent.GetVertex(endVertex.Next, out newTopVertex);
                    }
                    else
                    {
                        pair.Parent.GetVertex(endVertex.Prev, out newTopVertex);
                    }

                    RecalculateActiveEdge(ref horizontalEdge, ref endVertex, ref newTopVertex, horizontalEdge.BoundPairSide);
                    m_activeEdgeList[j] = horizontalEdge;

                    if (horizontalEdge.TopY == bottomY && horizontalEdge.DXdy != 0.0f)
                    {
                        float newEndX = horizontalEdge.BottomX + horizontalEdge.DXdy;
                        if (newEndX < endX || (newEndX == endX && horizontalEdge.Kind == PolygonType.CLIP && endType == PolygonType.SUBJECT))
                        {
                            endX = newEndX;
                            endType = horizontalEdge.Kind;
                        }
                    }
                    else
                    {
                        // The "horizontalEdge" is no longer horizontal :-) We intersect it with horizontal edges above
                        int risingEdge = j;
                        for (int k = j - 1; k >= from; --k)
                        {
                            var horizontalEdge2 = m_activeEdgeList[k];
                            Vector3 intersection = new Vector3(horizontalEdge.BottomX, bottomY, 0.0f);
                            var intersectionClassification = m_operation.ClassifyIntersection(horizontalEdge2.OutputSide, horizontalEdge2.Kind, horizontalEdge.OutputSide, horizontalEdge.Kind);
                            PerformIntersection(k, risingEdge, ref horizontalEdge2, ref horizontalEdge, ref intersection, intersectionClassification);
                            risingEdge = k;
                        }

                        ++from;
                    }
                }
                else
                {
                    float newEndX = horizontalEdge.BottomX + horizontalEdge.DXdy;
                    if (newEndX < endX || (newEndX == endX && horizontalEdge.Kind == PolygonType.CLIP && endType == PolygonType.SUBJECT))
                    {
                        endX = newEndX;
                        endType = horizontalEdge.Kind;
                    }
                }
            }
        }
Esempio n. 51
0
	/**
	 *	\brief Draws planes around the edges of a mesh.
	 *	@param _points The points to use as a guide.
	 *	@param _modifier Multiply plane X and Y dimensions component wise.
	 */
	public void DrawEdgePlanes(List<Vector2> _points, PolygonType convexity, Vector2 _modifier, float area)
	{
		Vector2[] points = _points.ToArray();

		if(convexity == PolygonType.ConcaveClockwise || convexity == PolygonType.ConvexClockwise)
			Array.Reverse(points);

		for(int i = 0; i < points.Length; i++)
		{
			float x1, x2, y1, y2;
			x1 = points[i].x;
			y1 = points[i].y;

			if(i > points.Length-2) {
				x2 = points[0].x;
				y2 = points[0].y;
			}
			else {
				x2 = points[i+1].x;
				y2 = points[i+1].y;			
			}

			float length = Vector2.Distance(new Vector2(x1, y1), new Vector2(x2, y2));
			length *= drawSettings.edgeLengthModifier;
			
			if(length < drawSettings.minLengthToDraw)
				continue;
		
			float angle = Mathf.Atan2(y2 - y1, x2 - x1) * Mathf.Rad2Deg;

			if( Mathf.Abs(angle) > 180-drawSettings.maxAngle && Mathf.Abs(angle) < 180+drawSettings.maxAngle)
				;
			else
				continue;

			GameObject boxColliderObj = new GameObject();
			
			boxColliderObj.AddComponent<MeshFilter>().sharedMesh = MeshPlane();
			boxColliderObj.AddComponent<MeshRenderer>();
			boxColliderObj.name = "EdgePlane " + angle;

			boxColliderObj.transform.position = new Vector3( ((x1 + x2)/2f), ((y1+y2)/2f), drawSettings.zPosition + drawSettings.edgeOffset);


			boxColliderObj.GetComponent<MeshRenderer>().sharedMaterial = drawSettings.edgeMaterial;
			Vector2[] uvs = boxColliderObj.GetComponent<MeshFilter>().sharedMesh.uv;

			float imgScale = 1f;
			if(drawSettings.edgeMaterial != null)
				imgScale = ((float)drawSettings.edgeMaterial.mainTexture.width / drawSettings.edgeMaterial.mainTexture.height);

			boxColliderObj.GetComponent<MeshFilter>().sharedMesh.uv = DrawUtility.ArrayMultiply(uvs, new Vector2( length / imgScale, 1f)).ToArray();

			if(drawSettings.areaRelativeHeight)
				boxColliderObj.transform.localScale = new Vector3(
					length,
					Mathf.Clamp(Mathf.Abs(area) * drawSettings.edgeHeight,
						drawSettings.minEdgeHeight,
						drawSettings.maxEdgeHeight),
						2f);
			else
				boxColliderObj.transform.localScale = new Vector3(length, drawSettings.edgeHeight, 2f);

			boxColliderObj.transform.rotation = Quaternion.Euler( new Vector3(0f, 0f, angle) );

			boxColliderObj.transform.parent = LastDrawnObject.transform;
		}		
	}