public void ArrangeOrientationsAllPaths(Path.Flags orientation) { if (orientation != Path.Flags.None) { uint start = 0; while (start < m_vertices.TotalVertices()) { start = ArrangeOrientations(start, orientation); } } }
public uint ArrangeOrientations(uint start, Path.Flags orientation) { if (orientation != Path.Flags.None) { while (start < m_vertices.TotalVertices()) { start = ArrangePolygonOrientation(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. path_flags_cw or path_flags_ccw //-------------------------------------------------------------------- public uint ArrangePolygonOrientation(uint start, Path.Flags orientation) { if (orientation == Path.Flags.None) { return(start); } // Skip all non-vertices at the beginning while (start < m_vertices.TotalVertices() && !Path.IsVertex(m_vertices.Command(start))) { ++start; } // Skip all insignificant move_to while (start + 1 < m_vertices.TotalVertices() && 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.TotalVertices() && !Path.IsNextPoly(m_vertices.Command(end))) { ++end; } if (end - start > 2) { if (PerceivePolygonOrientation(start, end) != orientation) { // Invert polygon, set orientation flag, and skip all end_poly InvertPolygon(start, end); uint PathAndFlags; while (end < m_vertices.TotalVertices() && Path.IsEndPoly(PathAndFlags = m_vertices.Command(end))) { m_vertices.ModifyCommand(end++, PathAndFlags | (uint)orientation);// Path.set_orientation(cmd, orientation)); } } } return(end); }