Clustering and Curve Fitting by Line Segments