libs: npd: integrate mesh cutting algorithm and fix a bug in it