#ifndef AGDBSOLIDHH #define AGDBSOLIDHH #include #include #include "ExpatInterface/Element.h" #include "agdbSection.hh" #include "agdbBase.hh" #include "agdbVolume.hh" #include "agdbAttribute.hh" #include "agdbMaterial.hh" #include "agdbInnerStruct.hh" namespace agdb { class Solid : public Volume { private: Material * _materialPtr; Attribute _materialAtt; Attribute _shape; Attribute _params; InnerStruct * _innerStruct; public: Solid() : Volume("solid"), //_name(), _materialPtr(0), _materialAtt("material", Attribute::required), _shape ("shape" , Attribute::required), _params ("dim" , Attribute::required), _innerStruct(0) { }; void putMeIn(xml::Element & parent) { // LESTER. Need checks. xml::Element * child = new xml::Element(); assert(child); parent.addChild(child); // Now destruction taken care of. child->setTagName(Volume::Base::getTagName()); child->addAttribute("name", Volume::getName()); //material // LESTER This will change when material is defined properly. if (_materialPtr) { // we point to a true material child->addAttribute("material", _materialPtr->getName()); } else { // We have to use an externally defined material. _materialAtt.addAttributeTo(child); } //shape _shape .addAttributeTo(child); //params _params.addAttributeTo(child); //innerstruct // LESTER Omit for the moment }; // Volume & setName(const string & s) { _name=s; return *this;}; // const string getName() { return _name; }; Solid & setMaterial(const std::string & name) { cerr << "WARNING. You are supplying me with the NAME of " << "a material (possibly beacuse the material is defined " << "elsewhere) rather than a REFERENCE to a material. " << "This means that I have no way of checking the " << "validity of this reference." << endl; assert(name!=static_cast("")); _materialAtt.setValue(name); return *this; }; Solid & setMaterial(Material & mat) { _materialPtr = &mat; return *this; }; Solid & setTrd() ; // LESTER Must complete. Solid & setInnerStruct() ; // LESTER Must complete. Solid & setBox(double xLength, double yLength, double zLength) { _shape.setValue("box"); _params.setValue(makeNumberString(xLength, yLength, zLength)); /* ostrstream o; o << xLength/DWmm << " " << yLength/DWmm << " " << zLength/DWmm << ends; _params = o.str(); */ return *this; }; Solid & setTubs(double rMin, double rMax, double zLength, double phi1 = 0.0*DWdegree, double phi2 = 360.0*DWdegree) { _shape.setValue("tubs"); /* ostrstream o; o << rMin/DWmm << " " << rMax/DWmm << " " << zLength/DWmm << " " << phi1/DWdegree << " " << phi2/DWdegree << ends; _params = o.str(); */ _params.setValue( makeNumberString(rMin,rMax,zLength)+" "+ makeNumberString(phi1, phi2)); return *this; }; Solid & setCons(double r1Min, double r1Max, double r2Min, double r2Max, double zLength, double phi1 = 0.0*DWdegree, double phi2 = 360.0*DWdegree) { _shape.setValue("cons"); /* ostrstream o; o << r1Min/DWmm << " " << r1Max/DWmm << " " << r2Min/DWmm << " " << r2Max/DWmm << " " << zLength/DWmm << " " << phi1/DWdegree << " " << phi2/DWdegree << ends; _params = o.str(); */ _params.setValue( makeNumberString(r1Min,r1Max)+" "+ makeNumberString(r2Min,r2Max)+" "+ makeNumberString(zLength)+" "+ makeNumberString(phi1, phi2) ); return *this; }; }; } #endif