12#include <Poco/AutoPtr.h>
13#include <Poco/DOM/Document.h>
48 const std::string &instName,
const std::string &xmlText);
52 enum CachingOption { NoneApplied, ReadGeomCache, ReadFallBack, WroteGeomCache, WroteCacheTemp };
59 void setComponentLinks(std::shared_ptr<Geometry::Instrument> &instrument, Poco::XML::Element *pRootElem,
62 std::string getMangledName();
65 static Poco::XML::Element *getParentComponent(
const Poco::XML::Element *pLocElem);
68 static std::string getNameOfLocationElement(
const Poco::XML::Element *pElem,
const Poco::XML::Element *pCompElem);
71 void saveDOM_Tree(std::string &outFilename);
74 CachingOption getAppliedCachingOption()
const;
77 const std::string createVTPFileName();
81 void initialise(
const std::string &filename,
const std::string &instName,
const std::string &xmlText,
82 const std::string &vtpFilename);
85 Poco::AutoPtr<Poco::XML::Document> getDocument();
88 void setLocation(
Geometry::IComponent *comp,
const Poco::XML::Element *pElem,
const double angleConvertConst,
89 const bool deltaOffsets =
false);
94 const double angleConvertConst,
const bool deltaOffsets =
false);
97 void setValidityRange(
const Poco::XML::Element *pRootElem);
100 void readDefaults(Poco::XML::Element *defaults);
115 bool empty() {
return vec.empty(); };
125 void populateIdList(Poco::XML::Element *pE, IdList &idList);
127 std::vector<std::string> buildExcludeList(
const Poco::XML::Element *
const location);
132 const Poco::XML::Element *pCompElem, IdList &idList);
135 bool isAssembly(
const std::string &)
const;
140 const Poco::XML::Element *pCompElem, IdList &idList);
143 const Poco::XML::Element *pCompElem,
const std::string &filename, IdList &idList,
144 const std::string &category);
147 const Poco::XML::Element *pCompElem,
const std::string &filename,
148 const Poco::XML::Element *pType);
151 const Poco::XML::Element *pCompElem,
const std::string &filename,
152 const Poco::XML::Element *pType);
155 const Poco::XML::Element *pCompElem,
const std::string &filename,
156 const Poco::XML::Element *pType);
160 const Poco::XML::Element *pCompElem, IdList &idList);
167 Kernel::V3D parseFacingElementToV3D(Poco::XML::Element *pElem);
178 CachingOption setupGeometryCache();
182 void createNeutronicInstrument();
190 void adjust(Poco::XML::Element *pElem, std::map<std::string, bool> &isTypeAssembly,
191 std::map<std::string, Poco::XML::Element *> &getTypeElement);
196 Poco::AutoPtr<Poco::XML::Document> convertLocationsElement(
const Poco::XML::Element *pElem);
200 double attrToDouble(
const Poco::XML::Element *pElem,
const std::string &name);
203 void getTypeAndComponentPointers(
const Poco::XML::Element *pRootElem, std::vector<Poco::XML::Element *> &typeElems,
204 std::vector<Poco::XML::Element *> &compElems)
const;
207 void throwIfTypeNameNotUnique(
const std::string &filename,
const std::string &typeName)
const;
212 Poco::XML::Element *pTypeElem,
const std::string &typeName);
216 void adjustTypesContainingCombineComponentsElement(
ShapeFactory &shapeCreator,
const std::string &filename,
217 const std::vector<Poco::XML::Element *> &typeElems,
218 size_t numberOfTypes);
221 void createVectorOfElementsContainingAParameterElement(Poco::XML::Element *pRootElem);
224 void checkIdListExistsAndDefinesEnoughIDs(
const IdList &idList, Poco::XML::Element *pElem,
225 const std::string &filename)
const;
228 void checkComponentContainsLocationElement(Poco::XML::Element *pElem,
const std::string &filename)
const;
231 void parseLocationsForEachTopLevelComponent(
Kernel::ProgressBase *progressReporter,
const std::string &filename,
232 const std::vector<Poco::XML::Element *> &compElems);
235 void collateTypeInformation(
const std::string &filename,
const std::vector<Poco::XML::Element *> &typeElems,
253 std::map<std::string, Poco::XML::Element *> &getTypeElement,
258 const std::string &cuboidName);
261 const std::string &cuboidName);
264 Poco::XML::Element *getShapeElement(
const Poco::XML::Element *pElem,
const std::string &name);
267 Kernel::V3D parsePosition(Poco::XML::Element *pElem);
279 Poco::AutoPtr<Poco::XML::Document>
m_pDoc;
340 double r, theta, phi;
341 SphVec() : r(0.0), theta(0.0), phi(0.0) {}
342 SphVec(
const double &r,
const double &theta,
const double &phi) : r(r), theta(theta), phi(phi) {}
Class for Assembly of geometric components.
base class for Geometric IComponent
Creates an instrument data from a XML instrument description file.
bool m_deltaOffsets
Flag to indicate whether offsets given in spherical coordinates are to be added to the current positi...
std::map< const Geometry::IComponent *, SphVec > m_tempPosHolder
Map to store positions of parent components in spherical coordinates.
double m_angleConvertConst
when this const equals 1 it means that angle=degree (default) is set in IDF otherwise if this const e...
bool m_haveDefaultFacing
True if defaults->components-are-facing is set in instrument def. file.
Kernel::V3D m_defaultFacing
Hold default facing position.
std::map< Geometry::IComponent *, Poco::XML::Element * > m_neutronicPos
A map containing the neutronic position for each detector.
IDFObject_const_sptr m_cacheFile
Input vtp file.
std::shared_ptr< Geometry::Instrument > m_instrument
For convenience added pointer to instrument here.
std::vector< Poco::XML::Element * > m_hasParameterElement
Holds all the xml elements that have a <parameter> child element.
~InstrumentDefinitionParser()=default
Poco::AutoPtr< Poco::XML::Document > m_pDoc
XML document is lazy loaded.
std::map< std::string, std::shared_ptr< Geometry::IObject > > mapTypeNameToShape
map which maps the type name to a shared pointer to a geometric shape
std::map< std::string, bool > isTypeAssembly
map which holds names of types and whether or not they are categorized as being assemblies,...
std::map< std::string, Poco::XML::Element * > getTypeElement
map which holds names of types and pointers to these type for fast retrieval in code
bool m_hasParameterElement_beenSet
has m_hasParameterElement been set - used when public method setComponentLinks is used
IDFObject_const_sptr m_xmlFile
Input xml file.
std::vector< Geometry::ObjComponent * > m_facingComponent
Container to hold all detectors and monitors added to the instrument.
std::string m_instName
Name of the instrument.
bool m_indirectPositions
Flag to indicate whether IDF contains physical & neutronic positions.
CachingOption m_cachingOption
Caching applied.
Object Component class, this class brings together the physical attributes of the component to the po...
Class originally intended to be used with the DataHandling 'LoadInstrument' algorithm.
std::map< std::pair< std::string, const IComponent * >, std::shared_ptr< XMLInstrumentParameter > > InstrumentParameterCache
Convenience typedef.
std::shared_ptr< const AbstractIDFObject > IDFObject_const_sptr
Helper class which provides the Collimation Length for SANS instruments.
Structure for holding detector IDs.
std::vector< int > vec
list of detector IDs
int counted
Used to count the number of detector encounted so far.
std::string idname
name of idlist
bool empty()
return true if empty
Stripped down vector that holds position in terms of spherical coordinates, Needed when processing in...