Size of the cockpit opening on the Formula 1 cars must comply with strict regulations. Compliance with these regulations is checked with special template placed in the cockpit.
Also, the cockpit has to meet a number of other requirements. The driver must be able to get out of the car without removing anything else except the steering wheel. With all seat belts fastened and with all safety equipment, the driver must be able to remove steering wheel and get out of the car in less than five seconds and replace the steering wheel in the next five seconds.
The survival cell, which protects driver in a collision, must extend at least 300 mm beyond the driver’s feet, which may not exceed the front wheels centre line.
On subsequent illustrations from FIA technical regulations you can see all the drawings related to the cockpit and the driver’s head protective padding around the cockpit.
FIA F1 2017. technical regulations can be downloaded here.