Morse complexes for shape segmentation and homological analysis: discrete models and algorithms