public CharacterGeometry(List<PolygonClosedWithNormalsD2D> characterContour, IndexedTriangles frontFace, double fontSize, double lineSpacing, double baseLine, double advanceWidth, double leftSideBearing, double rightSideBearing) { _characterContour = characterContour; _frontFace = frontFace; FontSize = fontSize; LineSpacing = lineSpacing; BaseLine = baseLine; AdvanceWidth = advanceWidth; LeftSideBearing = leftSideBearing; RightSideBearing = rightSideBearing; }
public CharacterGeometry(List <PolygonClosedWithNormalsD2D> characterContour, IndexedTriangles frontFace, double fontSize, double lineSpacing, double baseLine, double advanceWidth, double leftSideBearing, double rightSideBearing) { _characterContour = characterContour; _frontFace = frontFace; FontSize = fontSize; LineSpacing = lineSpacing; BaseLine = baseLine; AdvanceWidth = advanceWidth; LeftSideBearing = leftSideBearing; RightSideBearing = rightSideBearing; }
/// <summary> /// Triangulates the specified polygons. The result are indexed triangles. /// </summary> /// <param name="polygons">The polygons to triangulate.</param> /// <returns>Instance of the <see cref="IndexedTriangles"/> class, which holds the triangle vertices as well as the indices.</returns> private static IndexedTriangles Triangulate(IList <PolygonClosedD2D> polygons) { var triangles = GetTriangles(polygons); var pointList = new List <PointD2D>(); var pointToIndex = new Dictionary <PointD2D, int>(); var indexList = new List <int>(); foreach (var triangulatedPolygon in triangles) { foreach (var triangle in triangulatedPolygon.Triangles) { var p0 = new PointD2D(triangle.Points[0].X, triangle.Points[0].Y); var p1 = new PointD2D(triangle.Points[1].X, triangle.Points[1].Y); var p2 = new PointD2D(triangle.Points[2].X, triangle.Points[2].Y); if (!pointToIndex.TryGetValue(p0, out var i0)) { i0 = pointList.Count; pointToIndex.Add(p0, i0); pointList.Add(p0); } if (!pointToIndex.TryGetValue(p1, out var i1)) { i1 = pointList.Count; pointToIndex.Add(p1, i1); pointList.Add(p1); } if (!pointToIndex.TryGetValue(p2, out var i2)) { i2 = pointList.Count; pointToIndex.Add(p2, i2); pointList.Add(p2); } indexList.Add(i0); indexList.Add(i1); indexList.Add(i2); } } var indexedTriangles = new IndexedTriangles(pointList.ToArray(), indexList.ToArray()); return(indexedTriangles); }
/// <summary> /// Triangulates the specified polygons. The result are indexed triangles. /// </summary> /// <param name="polygons">The polygons to triangulate.</param> /// <returns>Instance of the <see cref="IndexedTriangles"/> class, which holds the triangle vertices as well as the indices.</returns> private static IndexedTriangles Triangulate(IList<PolygonClosedD2D> polygons) { var triangles = GetTriangles(polygons); var pointList = new List<PointD2D>(); var pointToIndex = new Dictionary<PointD2D, int>(); var indexList = new List<int>(); foreach (var triangulatedPolygon in triangles) { foreach (var triangle in triangulatedPolygon.Triangles) { var p0 = new PointD2D(triangle.Points[0].X, triangle.Points[0].Y); var p1 = new PointD2D(triangle.Points[1].X, triangle.Points[1].Y); var p2 = new PointD2D(triangle.Points[2].X, triangle.Points[2].Y); int i0, i1, i2; if (!pointToIndex.TryGetValue(p0, out i0)) { i0 = pointList.Count; pointToIndex.Add(p0, i0); pointList.Add(p0); } if (!pointToIndex.TryGetValue(p1, out i1)) { i1 = pointList.Count; pointToIndex.Add(p1, i1); pointList.Add(p1); } if (!pointToIndex.TryGetValue(p2, out i2)) { i2 = pointList.Count; pointToIndex.Add(p2, i2); pointList.Add(p2); } indexList.Add(i0); indexList.Add(i1); indexList.Add(i2); } } var indexedTriangles = new IndexedTriangles(pointList.ToArray(), indexList.ToArray()); return indexedTriangles; }