#include "G4MIRDBodyFactory.h"

#include "G4MIRDBrain.h"
#include "G4MIRDHead.h"
#include "G4MIRDHeart.h"
#include "G4MIRDLeftAdrenal.h"
#include "G4MIRDLeftArmBone.h"
#include "G4MIRDLeftBreast.h"
#include "G4MIRDLeftClavicle.h"
#include "G4MIRDLeftKidney.h"
#include "G4MIRDLeftLeg.h"
#include "G4MIRDLeftLegBone.h"
#include "G4MIRDLeftLung.h"
#include "G4MIRDLeftOvary.h"
#include "G4MIRDLeftScapula.h"
#include "G4MIRDLeftTeste.h"
#include "G4MIRDLiver.h"
#include "G4MIRDLowerLargeIntestine.h"
#include "G4MIRDMaleGenitalia.h"
#include "G4MIRDMiddleLowerSpine.h"
#include "G4MIRDPancreas.h"
#include "G4MIRDPelvis.h"
#include "G4MIRDRibCage.h"
#include "G4MIRDRightAdrenal.h"
#include "G4MIRDRightArmBone.h"
#include "G4MIRDRightBreast.h"
#include "G4MIRDRightClavicle.h"
#include "G4MIRDRightKidney.h"
#include "G4MIRDRightLeg.h"
#include "G4MIRDRightLegBone.h"
#include "G4MIRDRightLung.h"
#include "G4MIRDRightOvary.h"
#include "G4MIRDRightScapula.h"
#include "G4MIRDRightTeste.h"
#include "G4MIRDSkull.h"
#include "G4MIRDSmallIntestine.h"
#include "G4MIRDSpleen.h"
#include "G4MIRDStomach.h"
#include "G4MIRDThymus.h"
#include "G4MIRDThyroid.h"
#include "G4MIRDTrunk.h"
#include "G4MIRDUpperLargeIntestine.h"
#include "G4MIRDUpperSpine.h"
#include "G4MIRDUrinaryBladder.h"
#include "G4MIRDUterus.h"

G4MIRDBodyFactory::G4MIRDBodyFactory() {
    // Map with name of the organ and pointer to the MIRDOrgan class
    //  organ["ParameterisedRightBreast"] = new G4ParameterisedRightBreast();
    // organ["ParameterisedLeftBreast"] = new G4ParameterisedLeftBreast();
    organ["Head"] = new G4MIRDHead();
    organ["Trunk"] = new G4MIRDTrunk();
    organ["LeftLeg"] = new G4MIRDLeftLeg();
    organ["RightLeg"] = new G4MIRDRightLeg();

    organ["Skull"] = new G4MIRDSkull();
    organ["LeftArmBone"] = new G4MIRDLeftArmBone();
    organ["RightArmBone"] = new G4MIRDRightArmBone();
    organ["UpperSpine"] = new G4MIRDUpperSpine();
    organ["MiddleLowerSpine"] = new G4MIRDMiddleLowerSpine();
    organ["Pelvis"] = new G4MIRDPelvis();
    organ["RibCage"] = new G4MIRDRibCage();
    organ["LeftClavicle"] = new G4MIRDLeftClavicle();
    organ["RightClavicle"] = new G4MIRDRightClavicle();
    organ["LeftLegBone"] = new G4MIRDLeftLegBone();
    organ["RightLegBone"] = new G4MIRDRightLegBone();
    organ["LeftScapula"] = new G4MIRDLeftScapula();
    organ["RightScapula"] = new G4MIRDRightScapula();

    organ["Heart"] = new G4MIRDHeart();
    organ["Thyroid"] = new G4MIRDThyroid();
    organ["Thymus"] = new G4MIRDThymus();
    organ["MaleGenitalia"] = new G4MIRDMaleGenitalia();
    organ["Brain"] = new G4MIRDBrain();
    organ["Stomach"] = new G4MIRDStomach();
    organ["UpperLargeIntestine"] = new G4MIRDUpperLargeIntestine();
    organ["LowerLargeIntestine"] = new G4MIRDLowerLargeIntestine();
    organ["SmallIntestine"] = new G4MIRDSmallIntestine();
    organ["Spleen"] = new G4MIRDSpleen();
    organ["Pancreas"] = new G4MIRDPancreas();
    organ["LeftKidney"] = new G4MIRDLeftKidney();
    organ["RightKidney"] = new G4MIRDRightKidney();
    organ["UrinaryBladder"] = new G4MIRDUrinaryBladder();
    organ["Uterus"] = new G4MIRDUterus();
    organ["Liver"] = new G4MIRDLiver();
    organ["LeftLung"] = new G4MIRDLeftLung();
    organ["RightLung"] = new G4MIRDRightLung();
    organ["LeftOvary"] = new G4MIRDLeftOvary();
    organ["RightOvary"] = new G4MIRDRightOvary();
    organ["LeftTeste"] = new G4MIRDLeftTeste();
    organ["RightTeste"] = new G4MIRDRightTeste();
    organ["RightBreast"] = new G4MIRDRightBreast();
    organ["LeftBreast"] = new G4MIRDLeftBreast();
    organ["LeftAdrenal"] = new G4MIRDLeftAdrenal();
    organ["RightAdrenal"] = new G4MIRDRightAdrenal();
}

G4MIRDBodyFactory::~G4MIRDBodyFactory() {
    delete organ["Head"];
    organ["Head"] = 0;
    delete organ["RightLeg"];
    organ["RightLeg"] = 0;
    delete organ["LeftLeg"];
    organ["LeftLeg"] = 0;
    delete organ["Trunk"];
    organ["Trunk"] = 0;

    delete organ["RightScapula"];
    organ["RightScapula"] = 0;
    delete organ["LeftScapula"];
    organ["LeftScapula"] = 0;
    delete organ["RightLegBone"];
    organ["RightLegBone"] = 0;
    delete organ["LeftLegBone"];
    organ["LeftLegBone"] = 0;
    delete organ["RibCage"];
    organ["RibCage"] = 0;
    delete organ["MiddleLowerSpine"];
    organ["MidlleLowerSpine"] = 0;
    delete organ["UpperSpine"];
    organ["UpperSpine"] = 0;
    delete organ["Skull"];
    organ["Skull"] = 0;
    delete organ["RightArmBone"];
    organ["RightArmBone"] = 0;
    delete organ["LeftArmBone"];
    organ["LeftArmBone"] = 0;
    delete organ["RightClavicle"];
    organ["RightClavicle"] = 0;
    delete organ["LeftClavicle"];
    organ["LeftClavicle"] = 0;
    delete organ["Pelvis"];
    organ["Pelvis"] = 0;

    delete organ["RightAdrenal"];
    organ["RightAdrenal"] = 0;
    delete organ["LeftAdrenal"];
    organ["LeftAdrenal"] = 0;
    delete organ["LeftBreast"];
    organ["LeftBreast"] = 0;
    delete organ["RightBreast"];
    organ["RightBreast"] = 0;
    delete organ["RightOvary"];
    organ["RightOvary"] = 0;
    delete organ["LeftOvary"];
    organ["LeftOvary"] = 0;
    delete organ["RightTeste"];
    organ["RightTeste"] = 0;
    delete organ["LeftTeste"];
    organ["LeftTeste"] = 0;
    delete organ["RightLung"];
    organ["RightLung"] = 0;
    delete organ["LeftLung"];
    organ["LeftLung"] = 0;
    delete organ["Uterus"];
    organ["Uterus"] = 0;
    delete organ["UrinaryBladder"];
    organ["UrinaryBladder"] = 0;
    delete organ["RightKidney"];
    organ["RightKidney"] = 0;
    delete organ["LeftKidney"];
    organ["LeftKidney"] = 0;
    delete organ["Pancreas"];
    organ["Pancreas"] = 0;
    delete organ["Spleen"];
    organ["Spleen"] = 0;
    delete organ["LowerLargeIntestine"];
    organ["LowerLargeIntestine"] = 0;
    delete organ["SmallIntestine"];
    organ["SmallIntestine"] = 0;
    delete organ["UpperLargeIntestine"];
    organ["UpperLargeIntestine"] = 0;
    delete organ["Stomach"];
    organ["Stomach"] = 0;
    delete organ["Brain"];
    organ["Brain"] = 0;
    delete organ["Heart"];
    organ["Heart"] = 0;
    delete organ["Thymus"];
    organ["Thymus"] = 0;
    delete organ["MaleGenitalia"];
    organ["MaleGenitalia"] = 0;
    delete organ["Thyroid"];
    organ["Thyroid"] = 0;
    delete organ["Liver"];
    organ["Liver"] = 0;
}

G4VPhysicalVolume* G4MIRDBodyFactory::CreateOrgan(const G4String& organ_name, G4VPhysicalVolume* motherVolume,
                                                  const G4String& colourName, G4bool visAttribute, G4bool sensitivity) {
    return organ[organ_name]->Construct(organ_name, motherVolume, colourName, visAttribute, sensitivity);
}
