While I don't mean to condone this behavior, it seems like the TSA followed their own protocol in this case. (The protocol is inappropriate, but that is a different matter.)
The rules say that you must either go through the scanner or be patted down. "Remove your clothes for a visual inspection" is not one of the options.