private static ResourceClass.GWEDFile.PolygonStruct GetGWEDPolygon( FileStream fileStream, byte[] polyBuff, byte[] vtBuff, int offset) { // (1) get the polygon FileStruct.TSWedPolygon tsWedPolygon = (FileStruct.TSWedPolygon)ReadBuffer <FileStruct.TSWedPolygon> (fileStream, polyBuff, FileStruct.TSWedPolygonSize); ResourceClass.GWEDFile.PolygonStruct poly = ResourceClass.GWEDFile.CreatePolygonStruct(ref tsWedPolygon); // (2) get the set of points for each polygon long polypos = fileStream.Position; fileStream.Position = (tsWedPolygon.vertexStart * 4) + offset; for (int v = 0; v < tsWedPolygon.vertexCount; v++) { poly.vertices[v] = (XPoint)ReadBuffer <XPoint>(fileStream, vtBuff, 4); } fileStream.Position = polypos; return(poly); }
public static PolygonStruct CreatePolygonStruct(ref FileStruct.TSWedPolygon tsWedPolygon) { PolygonStruct ss = new PolygonStruct(); ss.flag = tsWedPolygon.flag; ss.boundBox.left = tsWedPolygon.minX; ss.boundBox.top = tsWedPolygon.minY; ss.boundBox.right = tsWedPolygon.maxX; ss.boundBox.bottom = tsWedPolygon.maxY; ss.vertices = new XPoint[tsWedPolygon.vertexCount]; return(ss); }