Measure the depth of the cushion cover from top to bottom. Pull the edge of the cover up until it is taught. Measure a corner with a seam to be sure you are measuring straight up and down.
Remove the cushion from the cover and measure the length and width of the cushion. Measure along the edge on the least damaged side.
Buy a piece of foam in the thickness you measured. Some stores, especially army supply or camping stores, will cut the foam to your measurements.
Cut the foam the length and width you measured, if required. Mark the dimensions on both sides of the foam. Use an electric knife to cut the foam. You may use shears and a serrated knife, if an electric knife is not available. Check frequently to be sure you are cutting straight down from the line on the top side to the line on the bottom side.
Replace the cushion in the cover.