The roommate could take out a restraining order prohibiting you from ever coming to the apartment.
When it comes to restraining orders, judges like to err on the side of caution so it shouldn't take much to get one no matter how much you swear that you aren't doing anything wrong.
Frankly, I think you are being an ahole for not respecting the roommate's living arrangement. There's no reason you have to be there when your girlfriend can visit you if she need's solace.
I suspect that a lot of her strife with her roommate is due to your presence. Once you stop going there, that should cool off.
Your girlfriend should get a place of her own if she wants you to visit frequently. Then there won't be any roommate to argue with.

