public void arrange_orientations_all_paths(Path.EPathFlags orientation) { if (orientation != Path.EPathFlags.None) { uint start = 0; while (start < m_vertices.total_vertices()) { start = arrange_orientations(start, orientation); } } }
public uint arrange_orientations(uint start, Path.EPathFlags orientation) { if (orientation != Path.EPathFlags.None) { while (start < m_vertices.total_vertices()) { start = arrange_polygon_orientation(start, orientation); if (Path.IsStop(m_vertices.command(start))) { ++start; break; } } } return(start); }
// Arrange the orientation of a polygon, all polygons in a path, // or in all paths. After calling arrange_orientations() or // arrange_orientations_all_paths(), all the polygons will have // the same orientation, i.e. Clockwise or CounterClockwise //-------------------------------------------------------------------- public uint arrange_polygon_orientation(uint start, Path.EPathFlags orientation) { if (orientation == Path.EPathFlags.None) { return(start); } // Skip all non-vertices At the beginning while (start < m_vertices.total_vertices() && !Path.IsVertex(m_vertices.command(start))) { ++start; } // Skip all insignificant MoveTo while (start + 1 < m_vertices.total_vertices() && Path.IsMoveTo(m_vertices.command(start)) && Path.IsMoveTo(m_vertices.command(start + 1))) { ++start; } // Find the last Vertex uint end = start + 1; while (end < m_vertices.total_vertices() && !Path.IsNextPoly(m_vertices.command(end))) { ++end; } if (end - start > 2) { if (perceive_polygon_orientation(start, end) != orientation) { // Invert polygon, Set orientation flag, and skip all end_poly invert_polygon(start, end); uint PathAndFlags; while (end < m_vertices.total_vertices() && Path.IsEndPoly(PathAndFlags = m_vertices.command(end))) { m_vertices.modify_command(end++, PathAndFlags | (uint)orientation);// Path.set_orientation(cmd, orientation)); } } } return(end); }