[metapost] Trying to figure out MPLib

Taco Hoekwater taco at elvenkind.com
Thu Aug 9 16:07:28 CEST 2012


On 08/09/2012 02:36 PM, Shriramana Sharma wrote:
> One small suggestion for change:
> mppath.h: extern int mp_cycle_knotpair (MP mp, mp_knot *p, mp_knot *q);
> mppath.c: int mp_cycle_knotpair (MP mp, mp_knot *p, mp_knot *q)
> mppath.h: extern int mp_final_knotpair (MP mp, mp_knot *p, mp_knot *q);
> mppath.c: int mp_final_knotpair (MP mp, mp_knot *q, mp_knot *first)
> Could you please change the labeling as following:
> mp_close_path (MP mp, mp_knot *p, mp_knot *first ) ;
> mp_close_path_cycle (MP mp, mp_knot *p, mp_knot *first ) ;

I've done that locally, but I will not post the code again.

> Actually in your code it's mp_cycle_knotpair and not final_knotpair.

True and in fact final_knotpair would not work, but that is just
ugly internals that are likely to change anyway.

> I think the only reason you need the cycle/final_knotpair here is to
> set the next pointer, left/right_type (to open) and tension (to 1). In
> which case, would it not be better to have another internal function
> "link_to" or something? Then you can substitute the mp_cycle_knotpair
> within append by that, and use cycle_knotpair (aka close_path_cycle)
> only to actually close the path. Of course, cycle_knotpair aka
> close_path_cycle would also use link_to to link the last knot to the
> first one.

Yes, and in fact it now looks like this:
int mp_close_path_cycle (MP mp, mp_knot *p, mp_knot *q)
	return mp_link_knotpair(mp,p,q)

Best wishes,

More information about the metapost mailing list