Constructing tree stem form from digitized surface measurements by a programming approach within discrete mathematics