"BUILDING HEIGHT - The vertical distance (measured from the grade level) to the highest level of the roof surface of flat roofs; to the deck line of mansard roofs;" QQQQQ...that part is fairly straight-forward.
"...or to the mean height between eaves and ridge for gable, gambrel or hip roofs." QQQQQ It may sound confusing, but all they're saying is that the height of these buildings is NOT measured from the ground to the height of the ridge. It's from the ground to the height midway between the top plate of the wall and the ridge. Example...a single-story house with 2' of foundation above grade, 9' of wall framing, and a gable roof with a 10' rise would be considered as a 2'+9'+5'=16' high structure.
"...building height does not apply to portions of buildings extending above the general roof line and comprising an aggregate area not greater than twenty-five percent (25%) of the total roof area, or to structures other than buildings." QQQQQ..This little disclaimer prevents things like cupolas and chimneys from being counted as part of the structure's height.