A robust workflow for b-rep generation from image masks