Millimeter and submillimeter observations of the Orion Bar. I. Physical structure