public void FromXml(XmlReader r) { corners = new Vector3[4]; int cornerNumber = 0; while (r.Read()) { if (r.NodeType == XmlNodeType.Whitespace) { continue; } for (int i = 0; i < r.AttributeCount; i++) { r.MoveToAttribute(i); // set the field in this object based on the element we just read if (r.Name == "kind") { kind = PolygonKindFromString(r.Value); break; } if (r.Name == "index") { index = int.Parse(r.Value); break; } } r.MoveToElement(); //Moves the reader back to the element node. // look for the start of an element if (r.NodeType == XmlNodeType.Element) { // parse that element // save the name of the element string elementName = r.Name; switch (elementName) { case "Corner": corners[cornerNumber++] = XmlHelperClass.ParseVectorAttributes(r); break; } } else if (r.NodeType == XmlNodeType.EndElement) { break; } } }
public static String PolygonKindToString(PolygonKind kind) { switch (kind) { case PolygonKind.Illegal: return("Illegal"); case PolygonKind.CV: return("CV"); case PolygonKind.Terrain: return("Terrain"); case PolygonKind.Bounding: return("Bounding"); default: return("Unknown PolygonKind " + (int)kind); } }
public static IList <Edge> BuildPolygonBoundary(Polygon polygon, PolygonKind polygonKind) { // Create a populated list of edges setting initial edge values. var edges = Enumerable .Range(0, polygon.Count) .Select(i => new Edge { Current = polygon[i], Kind = polygonKind }) .ToList(); // Initialise boundary edge links. for (var i = 0; i < polygon.Count; i++) { var prevI = i == 0 ? polygon.Count - 1 : i - 1; var nextI = (i + 1) % polygon.Count; edges[i].Next = edges[nextI]; edges[i].Prev = edges[prevI]; } // Initialise bottom, top, dx foreach (var edge in edges) { InitialiseGeometry(edge); } // Initialise minima, maxima, intermediate flags foreach (var edge in edges) { edge.EndIsLocalMinima = EndIsLocalMinima(edge); edge.EndIsLocalMaxima = EndIsLocalMaxima(edge); edge.IsIntermediate = !(edge.EndIsLocalMinima || edge.EndIsLocalMaxima); } return(edges); }
public static String PolygonKindToString(PolygonKind kind) { switch (kind) { case PolygonKind.Illegal: return "Illegal"; case PolygonKind.CV: return "CV"; case PolygonKind.Terrain: return "Terrain"; case PolygonKind.Bounding: return "Bounding"; default: return "Unknown PolygonKind " + (int)kind; } }
public PathPolygon(int index, PolygonKind kind, Vector3 [] corners) { this.kind = kind; this.index = index; this.corners = corners; }
/// <summary> /// Builds a free form such as a polygon or a Bezier curve etc. /// </summary> /// <param name="drawDoc">The draw document.</param> /// <param name="kind">The kind of freeform you want to create.</param> /// <param name="coordinates">The coordinates of the form(s). By adding more coordinate lists in the List, it will create a poly kind of the requested kind.</param> /// <param name="geometry">if set to <c>true</c> the 'Geometry' property is used (these are the untransformed bezier coordinates of the polygon). /// Normally you should use the absolute coordinates on the page! So use the default value <c>false</c>.</param> /// <returns>XShape</returns> public static Object BuildFreeForm(Object drawDoc, PolygonKind kind, List<List<PolyPointDescriptor>> coordinates = null, bool geometry = false) { XShape shape = null; switch (kind) { case PolygonKind.LINE: case PolygonKind.PLIN: // polygon open shape = OoDrawUtils.CreatePolylineShape(drawDoc); break; case PolygonKind.PATHPLIN: case PolygonKind.FREELINE: case PolygonKind.PATHLINE: // Freehand open, Curve shape = OoDrawUtils.CreateBezierShape(drawDoc, false); break; case PolygonKind.FREEFILL: case PolygonKind.PATHFILL: // Freehand filled, Curve filled shape = OoDrawUtils.CreateBezierShape(drawDoc); break; case PolygonKind.PATHPOLY: case PolygonKind.POLY: // polygon filled shape = OoDrawUtils.CreatePolygonShape(drawDoc); break; default: break; } SetPolyPoints(shape, coordinates, geometry); return shape; }