Modelling and Design of Photonic Bandgap Devices: a Microwave Accelerating Cavity for Cancer Hadrontherapy