An application of convex sets to the construction of error correcting codes and factorial designs