A pixel design method for mechanical metamaterials based on topology optimization