void VectorPath::CleanUp() { if (fPointCount == 0) return; bool notify = false; // remove last point if it is coincident with the first if (fClosed && fPointCount >= 1) { if (fPath[0].point == fPath[fPointCount - 1].point) { fPath[0].point_in = fPath[fPointCount - 1].point_in; _SetPointCount(fPointCount - 1); notify = true; } } for (int32 i = 0; i < fPointCount; i++) { // check for unnecessary, duplicate points if (i > 0) { if (fPath[i - 1].point == fPath[i].point && fPath[i - 1].point == fPath[i - 1].point_out && fPath[i].point == fPath[i].point_in) { // the previous point can be removed BPoint in = fPath[i - 1].point_in; if (RemovePoint(i - 1)) { i--; fPath[i].point_in = in; notify = true; } } } // re-establish connections of in-out control points if // they line up with the main control point if (fPath[i].point_in == fPath[i].point_out || fPath[i].point == fPath[i].point_out || fPath[i].point == fPath[i].point_in || (fabs(agg::calc_line_point_distance(fPath[i].point_in.x, fPath[i].point_in.y, fPath[i].point.x, fPath[i].point.y, fPath[i].point_out.x, fPath[i].point_out.y)) < 0.01 && fabs(agg::calc_line_point_distance(fPath[i].point_out.x, fPath[i].point_out.y, fPath[i].point.x, fPath[i].point.y, fPath[i].point_in.x, fPath[i].point_in.y)) < 0.01)) { fPath[i].connected = true; notify = true; } } if (notify) _NotifyPathChanged(); }
void VectorPath::ApplyTransform(const Transformable& transform) { if (transform.IsIdentity()) return; for (int32 i = 0; i < fPointCount; i++) { transform.Transform(&(fPath[i].point)); transform.Transform(&(fPath[i].point_out)); transform.Transform(&(fPath[i].point_in)); } _NotifyPathChanged(); }