Mantid
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::Geometry::InstrumentDefinitionParser Class Reference

Creates an instrument data from a XML instrument description file. More...

#include <InstrumentDefinitionParser.h>

Classes

struct  IdList
 Structure for holding detector IDs. More...
 
struct  SphVec
 Stripped down vector that holds position in terms of spherical coordinates, Needed when processing instrument definition files that use the 'Ariel format'. More...
 

Public Types

enum  CachingOption {
  NoneApplied , ReadGeomCache , ReadFallBack , WroteGeomCache ,
  WroteCacheTemp
}
 Caching. More...
 

Public Member Functions

const std::string createVTPFileName ()
 creates a vtp filename from a given xml filename More...
 
Kernel::V3D getAbsolutPositionInCompCoorSys (Geometry::ICompAssembly *comp, Kernel::V3D)
 return absolute position of point which is set relative to the coordinate system of the input component More...
 
CachingOption getAppliedCachingOption () const
 Getter the the applied caching option. More...
 
std::string getMangledName ()
 Handle used in the singleton constructor for instrument file should append the value file sha-1 checksum to determine if it is already in memory so that changes to the instrument file will cause file to be reloaded. More...
 
 InstrumentDefinitionParser ()
 Default Constructor - not very functional in this state. More...
 
 InstrumentDefinitionParser (const IDFObject_const_sptr &xmlFile, const IDFObject_const_sptr &expectedCacheFile, const std::string &instName, const std::string &xmlText)
 Construct the XML parser based on an IDF xml and cached vtp file objects. More...
 
 InstrumentDefinitionParser (const std::string &filename, const std::string &instName, const std::string &xmlText)
 Constructor. More...
 
std::shared_ptr< InstrumentparseXML (Kernel::ProgressBase *progressReporter)
 Parse XML contents. More...
 
void saveDOM_Tree (std::string &outFilename)
 Save DOM tree to xml file. More...
 
void setComponentLinks (std::shared_ptr< Geometry::Instrument > &instrument, Poco::XML::Element *pRootElem, Kernel::ProgressBase *progress=nullptr, const std::string &requestedDate=std::string())
 Add/overwrite any parameters specified in instrument with param values specified in <component-link> XML elements. More...
 
 ~InstrumentDefinitionParser ()=default
 

Static Public Member Functions

static std::string getNameOfLocationElement (const Poco::XML::Element *pElem, const Poco::XML::Element *pCompElem)
 get name of location element More...
 
static Poco::XML::Element * getParentComponent (const Poco::XML::Element *pLocElem)
 Get parent component element of location element. More...
 

Private Member Functions

void adjust (Poco::XML::Element *pElem, std::map< std::string, bool > &isTypeAssembly, std::map< std::string, Poco::XML::Element * > &getTypeElement)
 Takes as input a <type> element containing a <combine-components-into-one-shape>, and adjust the <type> element by replacing its containing <component> elements with <cuboid>'s (note for now this will only work for <cuboid>'s and when necessary this can be extended). More...
 
void adjustTypesContainingCombineComponentsElement (ShapeFactory &shapeCreator, const std::string &filename, const std::vector< Poco::XML::Element * > &typeElems, size_t numberOfTypes)
 Adjust each type which contains a <combine-components-into-one-shape> element. More...
 
void appendAssembly (Geometry::ICompAssembly *parent, const Poco::XML::Element *pLocElem, const Poco::XML::Element *pCompElem, IdList &idList)
 Add XML element to parent assuming the element contains other component elements. More...
 
void appendLeaf (Geometry::ICompAssembly *parent, const Poco::XML::Element *pLocElem, const Poco::XML::Element *pCompElem, IdList &idList)
 Add XML element to parent assuming the element contains no other component elements. More...
 
void appendLocations (Geometry::ICompAssembly *parent, const Poco::XML::Element *pLocElems, const Poco::XML::Element *pCompElem, IdList &idList)
 Append <locations> in a locations element. More...
 
void applyCache (const IDFObject_const_sptr &cacheToApply)
 Reads from a cache file. More...
 
double attrToDouble (const Poco::XML::Element *pElem, const std::string &name)
 return 0 if the attribute doesn't exist. More...
 
std::vector< std::string > buildExcludeList (const Poco::XML::Element *const location)
 
void checkComponentContainsLocationElement (Poco::XML::Element *pElem, const std::string &filename) const
 Check component has a <location> or <locations> element. More...
 
void checkIdListExistsAndDefinesEnoughIDs (const IdList &idList, Poco::XML::Element *pElem, const std::string &filename) const
 Check IdList. More...
 
void collateTypeInformation (const std::string &filename, const std::vector< Poco::XML::Element * > &typeElems, ShapeFactory &shapeCreator)
 Collect some information about types for later use. More...
 
Poco::AutoPtr< Poco::XML::Document > convertLocationsElement (const Poco::XML::Element *pElem)
 Take as input a <locations> element. More...
 
void createDetectorOrMonitor (Geometry::ICompAssembly *parent, const Poco::XML::Element *pLocElem, const Poco::XML::Element *pCompElem, const std::string &filename, IdList &idList, const std::string &category)
 
void createGridDetector (Geometry::ICompAssembly *parent, const Poco::XML::Element *pLocElem, const Poco::XML::Element *pCompElem, const std::string &filename, const Poco::XML::Element *pType)
 
void createNeutronicInstrument ()
 If appropriate, creates a second instrument containing neutronic detector positions. More...
 
void createRectangularDetector (Geometry::ICompAssembly *parent, const Poco::XML::Element *pLocElem, const Poco::XML::Element *pCompElem, const std::string &filename, const Poco::XML::Element *pType)
 
void createShapeIfTypeIsNotAnAssembly (Mantid::Geometry::ShapeFactory &shapeCreator, size_t iType, Poco::XML::Element *pTypeElem, const std::string &typeName)
 Record type as an assembly if it contains a component, otherwise create a shape for it. More...
 
void createStructuredDetector (Geometry::ICompAssembly *parent, const Poco::XML::Element *pLocElem, const Poco::XML::Element *pCompElem, const std::string &filename, const Poco::XML::Element *pType)
 
void createVectorOfElementsContainingAParameterElement (Poco::XML::Element *pRootElem)
 Create a vector of elements which contain a <parameter> More...
 
Poco::AutoPtr< Poco::XML::Document > getDocument ()
 lazy loads the document and returns a pointer More...
 
Kernel::V3D getRelativeTranslation (const Geometry::IComponent *comp, const Poco::XML::Element *pElem, const double angleConvertConst, const bool deltaOffsets=false)
 Calculate the position of comp relative to its parent from info provided by <location> element. More...
 
std::string getShapeCoorSysComp (Geometry::ICompAssembly *parent, Poco::XML::Element *pLocElem, std::map< std::string, Poco::XML::Element * > &getTypeElement, Geometry::ICompAssembly *&endAssembly)
 This method returns the parent appended which its child components and also name of type of the last child component. More...
 
Poco::XML::Element * getShapeElement (const Poco::XML::Element *pElem, const std::string &name)
 Return a subelement of an XML element. More...
 
void getTypeAndComponentPointers (const Poco::XML::Element *pRootElem, std::vector< Poco::XML::Element * > &typeElems, std::vector< Poco::XML::Element * > &compElems) const
 Populate vectors of pointers to type and component xml elements. More...
 
void initialise (const std::string &filename, const std::string &instName, const std::string &xmlText, const std::string &vtpFilename)
 shared Constructor logic More...
 
bool isAssembly (const std::string &) const
 Return true if assembly, false if not assembly and throws exception if string not in assembly. More...
 
void makeXYplaneFaceComponent (Geometry::IComponent *&in, const Geometry::ObjComponent *facing)
 Make the shape defined in 1st argument face the component in the second argument. More...
 
void makeXYplaneFaceComponent (Geometry::IComponent *&in, const Kernel::V3D &facingPoint)
 Make the shape defined in 1st argument face the position in the second argument. More...
 
Kernel::V3D parseFacingElementToV3D (Poco::XML::Element *pElem)
 Parse position of facing element to V3D. More...
 
void parseLocationsForEachTopLevelComponent (Kernel::ProgressBase *progressReporter, const std::string &filename, const std::vector< Poco::XML::Element * > &compElems)
 Aggregate locations and IDs for components. More...
 
Kernel::V3D parsePosition (Poco::XML::Element *pElem)
 Get position coordinates from XML element. More...
 
void populateIdList (Poco::XML::Element *pE, IdList &idList)
 Method for populating IdList. More...
 
void readDefaults (Poco::XML::Element *defaults)
 Reads the contents of the <defaults> element to set member variables,. More...
 
void setFacing (Geometry::IComponent *comp, const Poco::XML::Element *pElem)
 Set facing of comp as specified in XML facing element. More...
 
void setLocation (Geometry::IComponent *comp, const Poco::XML::Element *pElem, const double angleConvertConst, const bool deltaOffsets=false)
 Set location (position) of comp as specified in XML location element. More...
 
void setLogfile (const Geometry::IComponent *comp, const Poco::XML::Element *pElem, InstrumentParameterCache &logfileCache, const std::string &requestedDate=std::string())
 Set parameter/logfile info (if any) associated with component. More...
 
CachingOption setupGeometryCache ()
 Reads in or creates the geometry cache ('vtp') file. More...
 
void setValidityRange (const Poco::XML::Element *pRootElem)
 Check the validity range and add it to the instrument object. More...
 
void throwIfTypeNameNotUnique (const std::string &filename, const std::string &typeName) const
 Throw exception if type name is not unique in the IDF. More...
 
std::string translateRotateXMLcuboid (Geometry::ICompAssembly *comp, const Poco::XML::Element *cuboidEle, const std::string &cuboidName)
 Returns a translated and rotated <cuboid> element. More...
 
std::string translateRotateXMLcuboid (Geometry::ICompAssembly *comp, const std::string &cuboidXML, const std::string &cuboidName)
 Returns a translated and rotated <cuboid> element. More...
 
CachingOption writeAndApplyCache (IDFObject_const_sptr firstChoiceCache, IDFObject_const_sptr fallBackCache)
 Write out a cache file. More...
 

Private Attributes

std::map< std::string, Poco::XML::Element * > getTypeElement
 map which holds names of types and pointers to these type for fast retrieval in code More...
 
std::map< std::string, bool > isTypeAssembly
 map which holds names of types and whether or not they are categorized as being assemblies, which means whether the type element contains component elements More...
 
double m_angleConvertConst
 when this const equals 1 it means that angle=degree (default) is set in IDF otherwise if this const equals 180/pi it means that angle=radian is set in IDF More...
 
IDFObject_const_sptr m_cacheFile
 Input vtp file. More...
 
CachingOption m_cachingOption
 Caching applied. More...
 
Kernel::V3D m_defaultFacing
 Hold default facing position. More...
 
bool m_deltaOffsets
 Flag to indicate whether offsets given in spherical coordinates are to be added to the current position (true) or are a vector from the current position (false, default) More...
 
std::vector< Geometry::ObjComponent * > m_facingComponent
 Container to hold all detectors and monitors added to the instrument. More...
 
std::vector< Poco::XML::Element * > m_hasParameterElement
 Holds all the xml elements that have a <parameter> child element. More...
 
bool m_hasParameterElement_beenSet
 has m_hasParameterElement been set - used when public method setComponentLinks is used More...
 
bool m_haveDefaultFacing
 True if defaults->components-are-facing is set in instrument def. file. More...
 
bool m_indirectPositions
 Flag to indicate whether IDF contains physical & neutronic positions. More...
 
std::string m_instName
 Name of the instrument. More...
 
std::shared_ptr< Geometry::Instrumentm_instrument
 For convenience added pointer to instrument here. More...
 
std::map< Geometry::IComponent *, Poco::XML::Element * > m_neutronicPos
 A map containing the neutronic position for each detector. More...
 
Poco::AutoPtr< Poco::XML::Document > m_pDoc
 XML document is lazy loaded. More...
 
std::map< const Geometry::IComponent *, SphVecm_tempPosHolder
 Map to store positions of parent components in spherical coordinates. More...
 
IDFObject_const_sptr m_xmlFile
 Input xml file. More...
 
std::map< std::string, std::shared_ptr< Geometry::IObject > > mapTypeNameToShape
 map which maps the type name to a shared pointer to a geometric shape More...
 

Detailed Description

Creates an instrument data from a XML instrument description file.

Author
Nick Draper, Tessella Support Services plc
Date
19/11/2007
Author
Anders Markvardsen, ISIS, RAL
Date
7/3/2008

Definition at line 43 of file InstrumentDefinitionParser.h.

Member Enumeration Documentation

◆ CachingOption

Caching.

Enumerator
NoneApplied 
ReadGeomCache 
ReadFallBack 
WroteGeomCache 
WroteCacheTemp 

Definition at line 52 of file InstrumentDefinitionParser.h.

Constructor & Destructor Documentation

◆ InstrumentDefinitionParser() [1/3]

Mantid::Geometry::InstrumentDefinitionParser::InstrumentDefinitionParser ( )

Default Constructor - not very functional in this state.

Definition at line 65 of file InstrumentDefinitionParser.cpp.

References initialise().

◆ InstrumentDefinitionParser() [2/3]

Mantid::Geometry::InstrumentDefinitionParser::InstrumentDefinitionParser ( const std::string &  filename,
const std::string &  instName,
const std::string &  xmlText 
)

Constructor.

Parameters
filename:: IDF .xml path (full). This is needed mostly to find the instrument geometry cache.
instName:: name of the instrument
xmlText:: XML contents of IDF

Definition at line 78 of file InstrumentDefinitionParser.cpp.

References initialise().

◆ InstrumentDefinitionParser() [3/3]

Mantid::Geometry::InstrumentDefinitionParser::InstrumentDefinitionParser ( const IDFObject_const_sptr xmlFile,
const IDFObject_const_sptr expectedCacheFile,
const std::string &  instName,
const std::string &  xmlText 
)

Construct the XML parser based on an IDF xml and cached vtp file objects.

Parameters
xmlFile:: The xml file, here wrapped in a IDFObject
expectedCacheFile:: Expected vtp cache file
instName:: Instrument name
xmlText:: XML contents of IDF

Definition at line 94 of file InstrumentDefinitionParser.cpp.

References initialise(), and m_cacheFile.

◆ ~InstrumentDefinitionParser()

Mantid::Geometry::InstrumentDefinitionParser::~InstrumentDefinitionParser ( )
default

Member Function Documentation

◆ adjust()

void Mantid::Geometry::InstrumentDefinitionParser::adjust ( Poco::XML::Element *  pElem,
std::map< std::string, bool > &  isTypeAssembly,
std::map< std::string, Poco::XML::Element * > &  getTypeElement 
)
private

Takes as input a <type> element containing a <combine-components-into-one-shape>, and adjust the <type> element by replacing its containing <component> elements with <cuboid>'s (note for now this will only work for <cuboid>'s and when necessary this can be extended).

Parameters
pElem:: Poco::XML <type> element that we want to adjust
isTypeAssembly[in] :: tell whether any other type, but the special one treated here, is assembly or not
getTypeElement[in] :: contain pointers to all types but the onces treated here
Exceptions
InstrumentDefinitionErrorThrown if issues with the content of XML instrument file

Definition at line 2615 of file InstrumentDefinitionParser.cpp.

References getParentComponent(), getShapeCoorSysComp(), getTypeElement, isTypeAssembly, m_angleConvertConst, setLocation(), translateRotateXMLcuboid(), and UNUSED_ARG.

Referenced by adjustTypesContainingCombineComponentsElement().

◆ adjustTypesContainingCombineComponentsElement()

void Mantid::Geometry::InstrumentDefinitionParser::adjustTypesContainingCombineComponentsElement ( ShapeFactory shapeCreator,
const std::string &  filename,
const std::vector< Poco::XML::Element * > &  typeElems,
size_t  numberOfTypes 
)
private

Adjust each type which contains a <combine-components-into-one-shape> element.

"Adjust" (see adjust method) each type which contains a <combine-components-into-one-shape> element

Parameters
shapeCreator:: Factory for creating a shape
filename:: Name of the IDF file
typeElems:: Vector of pointers to type elements
numberOfTypes:: Total number of type elements

Definition at line 455 of file InstrumentDefinitionParser.cpp.

References adjust(), Mantid::Geometry::ShapeFactory::createShape(), getTypeElement, isTypeAssembly, mapTypeNameToShape, and throwIfTypeNameNotUnique().

Referenced by collateTypeInformation().

◆ appendAssembly()

void Mantid::Geometry::InstrumentDefinitionParser::appendAssembly ( Geometry::ICompAssembly parent,
const Poco::XML::Element *  pLocElem,
const Poco::XML::Element *  pCompElem,
IdList idList 
)
private

Add XML element to parent assuming the element contains other component elements.

Assumes second argument is a XML location element and its parent is a component element which is assigned to be an assembly.

This method appends the parent component element of the location element to the CompAssembly passed as the 1st arg. Note this method may call itself, i.e. it may act recursively.

Parameters
parent:: CompAssembly to append new component to
pLocElem:: Poco::XML element that points to a location element in an instrument description XML file, which optionally may be detached (meaning it is not required to be part of the DOM tree of the IDF)
pCompElem:: The Poco::XML <component> element that contains the <location> element
idList:: The current IDList

Definition at line 1076 of file InstrumentDefinitionParser.cpp.

References appendAssembly(), appendLeaf(), appendLocations(), buildExcludeList(), Mantid::Geometry::g_log, getNameOfLocationElement(), getParentComponent(), getTypeElement, Mantid::Geometry::InstrumentDefinitionParser::IdList::idname, isAssembly(), m_angleConvertConst, m_deltaOffsets, m_indirectPositions, m_instrument, m_neutronicPos, m_xmlFile, mapTypeNameToShape, obj, populateIdList(), Mantid::Geometry::InstrumentDefinitionParser::IdList::reset(), setFacing(), setLocation(), setLogfile(), and Mantid::Kernel::Logger::warning().

Referenced by appendAssembly(), appendLocations(), and parseLocationsForEachTopLevelComponent().

◆ appendLeaf()

void Mantid::Geometry::InstrumentDefinitionParser::appendLeaf ( Geometry::ICompAssembly parent,
const Poco::XML::Element *  pLocElem,
const Poco::XML::Element *  pCompElem,
IdList idList 
)
private

Add XML element to parent assuming the element contains no other component elements.

Assumes second argument is pointing to a leaf, which here means the location element (indirectly representing a component element) that contains no sub-components.

This component is appended to the parent (1st argument).

Parameters
parent:: CompAssembly to append component to
pLocElem:: Poco::XML element that points to the element in the XML doc we want to add, which optionally may be detached (meaning it is not required to be part of the DOM tree of the IDF)
pCompElem:: The Poco::XML <component> element that contains the <location> element, which may optionally be detached from the DOM tree also
idList:: The current IDList
Exceptions
InstrumentDefinitionErrorThrown if issues with the content of XML instrument file

Definition at line 1645 of file InstrumentDefinitionParser.cpp.

References Mantid::Geometry::ICompAssembly::add(), Mantid::Geometry::GridDetector::compareName(), Mantid::Geometry::RectangularDetector::compareName(), Mantid::Geometry::StructuredDetector::compareName(), createDetectorOrMonitor(), createGridDetector(), createRectangularDetector(), createStructuredDetector(), getNameOfLocationElement(), getTypeElement, Mantid::Geometry::InstrumentDefinitionParser::IdList::idname, m_angleConvertConst, m_deltaOffsets, m_instrument, m_xmlFile, mapTypeNameToShape, populateIdList(), Mantid::Geometry::InstrumentDefinitionParser::IdList::reset(), setFacing(), setLocation(), and setLogfile().

Referenced by appendAssembly(), appendLocations(), and parseLocationsForEachTopLevelComponent().

◆ appendLocations()

void Mantid::Geometry::InstrumentDefinitionParser::appendLocations ( Geometry::ICompAssembly parent,
const Poco::XML::Element *  pLocElems,
const Poco::XML::Element *  pCompElem,
IdList idList 
)
private

Append <locations> in a locations element.

Assumes second argument is a XML location element and its parent is a component element which is assigned to be an assembly.

This method appends the parent component element of the location element to the CompAssembly passed as the 1st arg. Note this method may call itself, i.e. it may act recursively.

Parameters
parent:: CompAssembly to append new component to
pLocElems:: Poco::XML element that points to a locations element in an instrument description XML file, which optionally may be detached (meaning it is not required to be part of the DOM tree of the IDF)
pCompElem:: The Poco::XML <component> element that contains the <locations> element
idList:: The current IDList

Definition at line 552 of file InstrumentDefinitionParser.cpp.

References appendAssembly(), appendLeaf(), convertLocationsElement(), and isAssembly().

Referenced by appendAssembly(), and parseLocationsForEachTopLevelComponent().

◆ applyCache()

void Mantid::Geometry::InstrumentDefinitionParser::applyCache ( const IDFObject_const_sptr cacheToApply)
private

Reads from a cache file.

Apply the cache.

Parameters
cacheToApply: Cache file object to use the the geometries.

Definition at line 2472 of file InstrumentDefinitionParser.cpp.

References Mantid::Geometry::g_log, Mantid::Kernel::Logger::information(), and mapTypeNameToShape.

Referenced by setupGeometryCache().

◆ attrToDouble()

double Mantid::Geometry::InstrumentDefinitionParser::attrToDouble ( const Poco::XML::Element *  pElem,
const std::string &  name 
)
private

return 0 if the attribute doesn't exist.

This is to follow the behavior of atof which always returns 0 if there is a problem.

Definition at line 600 of file InstrumentDefinitionParser.cpp.

References Mantid::Geometry::g_log, value, and Mantid::Kernel::Logger::warning().

Referenced by createGridDetector(), createRectangularDetector(), createStructuredDetector(), getRelativeTranslation(), parseFacingElementToV3D(), parsePosition(), setFacing(), setLocation(), and setLogfile().

◆ buildExcludeList()

std::vector< std::string > Mantid::Geometry::InstrumentDefinitionParser::buildExcludeList ( const Poco::XML::Element *const  location)
private

Definition at line 1046 of file InstrumentDefinitionParser.cpp.

Referenced by appendAssembly().

◆ checkComponentContainsLocationElement()

void Mantid::Geometry::InstrumentDefinitionParser::checkComponentContainsLocationElement ( Poco::XML::Element *  pElem,
const std::string &  filename 
) const
private

Check component has a <location> or <locations> element.

Component must contain a <location> or <locations> Throw an exception if it does not.

Parameters
pElem:: Element with the idlist
filename:: Name of the IDF, for exception message

Definition at line 372 of file InstrumentDefinitionParser.cpp.

References Mantid::Kernel::Logger::error(), and Mantid::Geometry::g_log.

Referenced by parseLocationsForEachTopLevelComponent().

◆ checkIdListExistsAndDefinesEnoughIDs()

void Mantid::Geometry::InstrumentDefinitionParser::checkIdListExistsAndDefinesEnoughIDs ( const IdList idList,
Poco::XML::Element *  pElem,
const std::string &  filename 
) const
private

Check IdList.

Check that the required IdList exists in the IDF and defines a sufficient number of IDs.

Parameters
idList:: The IdList
pElem:: Element with the idlist
filename:: Name of the IDF, for exception message

Definition at line 398 of file InstrumentDefinitionParser.cpp.

References Mantid::Geometry::InstrumentDefinitionParser::IdList::counted, Mantid::Kernel::Logger::error(), Mantid::Geometry::g_log, and Mantid::Geometry::InstrumentDefinitionParser::IdList::vec.

Referenced by parseLocationsForEachTopLevelComponent().

◆ collateTypeInformation()

void Mantid::Geometry::InstrumentDefinitionParser::collateTypeInformation ( const std::string &  filename,
const std::vector< Poco::XML::Element * > &  typeElems,
ShapeFactory shapeCreator 
)
private

Collect some information about types for later use.

Collect some information about types for later use including:

  • populate directory getTypeElement
  • populate directory isTypeAssembly
  • create shapes for all none assembly components and store in mapTypeNameToShape
  • If 'Outline' attribute set for assembly add attribute object_created=no to indicate the shape for this assembly should be created later.
Parameters
filename:: Name of the IDF, for exception message
typeElems:: Vector of pointers to type elements
shapeCreator:: Factory for creating a shape

Definition at line 291 of file InstrumentDefinitionParser.cpp.

References adjustTypesContainingCombineComponentsElement(), createShapeIfTypeIsNotAnAssembly(), getTypeElement, and throwIfTypeNameNotUnique().

Referenced by parseXML().

◆ convertLocationsElement()

Poco::AutoPtr< Poco::XML::Document > Mantid::Geometry::InstrumentDefinitionParser::convertLocationsElement ( const Poco::XML::Element *  pElem)
private

Take as input a <locations> element.

Such an element is a short-hand notation for a sequence of <location> elements. This method return this sequence as a xml string

Such an element is a short-hand notation for a sequence of <location> elements. This method return this sequence as a xml string

Parameters
pElemInput <locations> element
Returns
XML document containing <location> elements
Exceptions
InstrumentDefinitionErrorThrown if issues with the content of XML instrument file

Definition at line 2832 of file InstrumentDefinitionParser.cpp.

References n, Mantid::Kernel::Strings::strip(), and std::to_string().

Referenced by appendLocations().

◆ createDetectorOrMonitor()

void Mantid::Geometry::InstrumentDefinitionParser::createDetectorOrMonitor ( Geometry::ICompAssembly parent,
const Poco::XML::Element *  pLocElem,
const Poco::XML::Element *  pCompElem,
const std::string &  filename,
IdList idList,
const std::string &  category 
)
private

◆ createGridDetector()

void Mantid::Geometry::InstrumentDefinitionParser::createGridDetector ( Geometry::ICompAssembly parent,
const Poco::XML::Element *  pLocElem,
const Poco::XML::Element *  pCompElem,
const std::string &  filename,
const Poco::XML::Element *  pType 
)
private

◆ createNeutronicInstrument()

void Mantid::Geometry::InstrumentDefinitionParser::createNeutronicInstrument ( )
private

If appropriate, creates a second instrument containing neutronic detector positions.

Definition at line 2560 of file InstrumentDefinitionParser.cpp.

References m_angleConvertConst, m_deltaOffsets, m_instrument, m_neutronicPos, mapTypeNameToShape, setLocation(), and Mantid::Geometry::ObjComponent::setShape().

Referenced by parseXML().

◆ createRectangularDetector()

void Mantid::Geometry::InstrumentDefinitionParser::createRectangularDetector ( Geometry::ICompAssembly parent,
const Poco::XML::Element *  pLocElem,
const Poco::XML::Element *  pCompElem,
const std::string &  filename,
const Poco::XML::Element *  pType 
)
private

◆ createShapeIfTypeIsNotAnAssembly()

void Mantid::Geometry::InstrumentDefinitionParser::createShapeIfTypeIsNotAnAssembly ( Mantid::Geometry::ShapeFactory shapeCreator,
size_t  iType,
Poco::XML::Element *  pTypeElem,
const std::string &  typeName 
)
private

Record type as an assembly if it contains a component, otherwise create a shape for it.

If type does not contain a component element then it is not an assembly and a shape can be created.

Parameters
shapeCreator:: Factory for creating a shape
iType:: The i-th type
pTypeElem:: Pointer to the type element
typeName:: Name of the type

Definition at line 495 of file InstrumentDefinitionParser.cpp.

References Mantid::Geometry::ShapeFactory::createShape(), isTypeAssembly, and mapTypeNameToShape.

Referenced by collateTypeInformation().

◆ createStructuredDetector()

void Mantid::Geometry::InstrumentDefinitionParser::createStructuredDetector ( Geometry::ICompAssembly parent,
const Poco::XML::Element *  pLocElem,
const Poco::XML::Element *  pCompElem,
const std::string &  filename,
const Poco::XML::Element *  pType 
)
private

◆ createVectorOfElementsContainingAParameterElement()

void Mantid::Geometry::InstrumentDefinitionParser::createVectorOfElementsContainingAParameterElement ( Poco::XML::Element *  pRootElem)
private

Create a vector of elements which contain a <parameter>

Parameters
pRootElem:: Pointer to the root element

Definition at line 425 of file InstrumentDefinitionParser.cpp.

References m_hasParameterElement, and m_hasParameterElement_beenSet.

Referenced by parseXML().

◆ createVTPFileName()

const std::string Mantid::Geometry::InstrumentDefinitionParser::createVTPFileName ( )

creates a vtp filename from a given xml filename

Generates a vtp filename from a xml filename.

Returns
The vtp filename

Definition at line 2943 of file InstrumentDefinitionParser.cpp.

References getMangledName(), and Mantid::Kernel::SingletonHolder< T >::Instance().

Referenced by initialise().

◆ getAbsolutPositionInCompCoorSys()

V3D Mantid::Geometry::InstrumentDefinitionParser::getAbsolutPositionInCompCoorSys ( Geometry::ICompAssembly comp,
Kernel::V3D  pos 
)

return absolute position of point which is set relative to the coordinate system of the input component

Parameters
compReference coordinate system
posA position relative to the coord. sys. of comp
Returns
absolute position

Definition at line 2788 of file InstrumentDefinitionParser.cpp.

References Mantid::Geometry::ICompAssembly::add(), Mantid::Geometry::Component::getPos(), and Mantid::Geometry::Component::setPos().

Referenced by translateRotateXMLcuboid().

◆ getAppliedCachingOption()

InstrumentDefinitionParser::CachingOption Mantid::Geometry::InstrumentDefinitionParser::getAppliedCachingOption ( ) const

Getter the the applied caching option.

Getter for the applied caching option.

Returns
selected caching.

Definition at line 2556 of file InstrumentDefinitionParser.cpp.

References m_cachingOption.

◆ getDocument()

Poco::AutoPtr< Poco::XML::Document > Mantid::Geometry::InstrumentDefinitionParser::getDocument ( )
private

lazy loads the document and returns a pointer

Lazy loads the document and returns a autopointer.

Returns
an autopointer to the xml document

Definition at line 172 of file InstrumentDefinitionParser.cpp.

References m_instrument, and m_pDoc.

Referenced by parseXML(), and saveDOM_Tree().

◆ getMangledName()

std::string Mantid::Geometry::InstrumentDefinitionParser::getMangledName ( )

Handle used in the singleton constructor for instrument file should append the value file sha-1 checksum to determine if it is already in memory so that changes to the instrument file will cause file to be reloaded.

Returns
a mangled name combining the filename and the checksum attribute of the XML contents

Definition at line 152 of file InstrumentDefinitionParser.cpp.

References m_instName, m_instrument, m_xmlFile, and Mantid::Kernel::ChecksumHelper::sha1FromString().

Referenced by createVTPFileName(), Mantid::DataHandling::LoadInstrument::exec(), Mantid::DataHandling::LoadMcStas::readEventData(), MantidQt::MantidWidgets::SlitCalculator::setInstrument(), Mantid::API::ExperimentInfo::setInstumentFromXML(), and setupGeometryCache().

◆ getNameOfLocationElement()

std::string Mantid::Geometry::InstrumentDefinitionParser::getNameOfLocationElement ( const Poco::XML::Element *  pElem,
const Poco::XML::Element *  pCompElem 
)
static

get name of location element

Get name of a location element.

It will return the value of the attribute 'name', or the parent's name attribute, or the parent's type, if all else fails.

Parameters
pElem:: Poco::XML element that points to a <location> element, which optionally may be detached (meaning it is not required to be part of the DOM tree of the IDF)
pCompElem:: The Poco::XML <component> element that contain the location element, which may optionally be detached from the DOM tree also
Returns
name of location element

Definition at line 871 of file InstrumentDefinitionParser.cpp.

Referenced by appendAssembly(), appendLeaf(), createDetectorOrMonitor(), createGridDetector(), createRectangularDetector(), createStructuredDetector(), and getShapeCoorSysComp().

◆ getParentComponent()

Poco::XML::Element * Mantid::Geometry::InstrumentDefinitionParser::getParentComponent ( const Poco::XML::Element *  pLocElem)
static

Get parent component element of location element.

Get parent <component> element of <location> element.

Parameters
pLocElem:: Poco::XML element that points a location element in the XML doc
Returns
Parent XML element to a location XML element
Exceptions
logic_errorThrown if argument is not a child of component element

Definition at line 824 of file InstrumentDefinitionParser.cpp.

References Mantid::Kernel::Logger::error(), and Mantid::Geometry::g_log.

Referenced by adjust(), appendAssembly(), and getShapeCoorSysComp().

◆ getRelativeTranslation()

Kernel::V3D Mantid::Geometry::InstrumentDefinitionParser::getRelativeTranslation ( const Geometry::IComponent comp,
const Poco::XML::Element *  pElem,
const double  angleConvertConst,
const bool  deltaOffsets = false 
)
private

Calculate the position of comp relative to its parent from info provided by <location> element.

Parameters
comp:: To set position/location off
pElem:: Poco::XML element that points a <location> element, which optionally may be detached (meaning it is not required to be part of the DOM tree of the IDF)
angleConvertConst:: constant for converting deg to rad
deltaOffsets:: radial position offsets
Returns
Thrown if second argument is not a pointer to a 'location' XML element

Definition at line 736 of file InstrumentDefinitionParser.cpp.

References attrToDouble(), Mantid::Geometry::IComponent::getParent(), m_tempPosHolder, Mantid::Kernel::V3D::spherical(), tmp, Mantid::Geometry::x, Mantid::Geometry::y, and Mantid::Geometry::z.

Referenced by setLocation().

◆ getShapeCoorSysComp()

std::string Mantid::Geometry::InstrumentDefinitionParser::getShapeCoorSysComp ( Geometry::ICompAssembly parent,
Poco::XML::Element *  pLocElem,
std::map< std::string, Poco::XML::Element * > &  getTypeElement,
Geometry::ICompAssembly *&  endAssembly 
)
private

This method returns the parent appended which its child components and also name of type of the last child component.

Adds component with coordinate system as defined by the input <location> element to the input parent component.

Nested <location> elements are allowed and this method is recursive. As this method is running recursively it will eventually return a leaf component (in endAssembly) and the name of the <type> of this leaf

Parameters
parent:: CompAssembly Parent component
pLocElem:: Poco::XML element that points to a location element
getTypeElement:: contain pointers to all <type>s
endAssembly:: Output child component, which coor. sys. modified according to pLocElem
Returns
Returns <type> name
Exceptions
InstrumentDefinitionErrorThrown if issues with the content of XML instrument file

Definition at line 3032 of file InstrumentDefinitionParser.cpp.

References getNameOfLocationElement(), getParentComponent(), getShapeCoorSysComp(), getTypeElement, m_angleConvertConst, and setLocation().

Referenced by adjust(), and getShapeCoorSysComp().

◆ getShapeElement()

Poco::XML::Element * Mantid::Geometry::InstrumentDefinitionParser::getShapeElement ( const Poco::XML::Element *  pElem,
const std::string &  name 
)
private

Return a subelement of an XML element.

Return a subelement of an XML element, but also checks that there exist exactly one entry of this subelement.

Parameters
pElem:: XML from instrument def. file
name:: Name of subelement
Returns
The subelement
Exceptions
std::invalid_argumentThrown if issues with XML string

Definition at line 2965 of file InstrumentDefinitionParser.cpp.

Referenced by translateRotateXMLcuboid().

◆ getTypeAndComponentPointers()

void Mantid::Geometry::InstrumentDefinitionParser::getTypeAndComponentPointers ( const Poco::XML::Element *  pRootElem,
std::vector< Poco::XML::Element * > &  typeElems,
std::vector< Poco::XML::Element * > &  compElems 
) const
private

Populate vectors of pointers to type and component xml elements.

Create vectors of pointers to <type>s and <component>s".

Parameters
pRootElem:: Pointer to the root element
typeElems:: Reference to type vector to populate
compElems:: Reference to component vector to populate

Definition at line 523 of file InstrumentDefinitionParser.cpp.

Referenced by parseXML().

◆ initialise()

void Mantid::Geometry::InstrumentDefinitionParser::initialise ( const std::string &  filename,
const std::string &  instName,
const std::string &  xmlText,
const std::string &  vtpFilename 
)
private

shared Constructor logic

Initialise method used in Constructor.

Parameters
filename:: IDF .xml path (full). This is needed mostly to find the instrument geometry cache.
instName:: name of the instrument
xmlText:: XML contents of IDF
vtpFilename:: the path to the vtp file if you want to override the default

Definition at line 114 of file InstrumentDefinitionParser.cpp.

References createVTPFileName(), m_cacheFile, m_instName, m_instrument, and m_xmlFile.

Referenced by InstrumentDefinitionParser().

◆ isAssembly()

bool Mantid::Geometry::InstrumentDefinitionParser::isAssembly ( const std::string &  type) const
private

Return true if assembly, false if not assembly and throws exception if string not in assembly.

Returns True if the (string) type given is an assembly.

Parameters
type:: name of the type of a component in XML instrument definition
Returns
True if the type is an assembly
Exceptions
InstrumentDefinitionErrorThrown if type not defined in XML definition

Definition at line 1868 of file InstrumentDefinitionParser.cpp.

References isTypeAssembly, and m_xmlFile.

Referenced by appendAssembly(), appendLocations(), and parseLocationsForEachTopLevelComponent().

◆ makeXYplaneFaceComponent() [1/2]

void Mantid::Geometry::InstrumentDefinitionParser::makeXYplaneFaceComponent ( Geometry::IComponent *&  in,
const Geometry::ObjComponent facing 
)
private

Make the shape defined in 1st argument face the component in the second argument.

Make the shape defined in 1st argument face the component in the second argument, by rotating the z-axis of the component passed in 1st argument so that it points in the direction: from the component as specified 2nd argument to the component as specified in 1st argument.

Parameters
in:: Component to be rotated
facing:: Object to face

Definition at line 1890 of file InstrumentDefinitionParser.cpp.

References Mantid::Geometry::Component::getPos(), and makeXYplaneFaceComponent().

Referenced by createGridDetector(), createRectangularDetector(), createStructuredDetector(), makeXYplaneFaceComponent(), and setFacing().

◆ makeXYplaneFaceComponent() [2/2]

void Mantid::Geometry::InstrumentDefinitionParser::makeXYplaneFaceComponent ( Geometry::IComponent *&  in,
const Kernel::V3D facingPoint 
)
private

Make the shape defined in 1st argument face the position in the second argument.

Make the shape defined in 1st argument face the position in the second argument, by rotating the z-axis of the component passed in 1st argument so that it points in the direction: from the position (as specified 2nd argument) to the component (1st argument).

Parameters
in:: Component to be rotated
facingPoint:: position to face

Definition at line 1904 of file InstrumentDefinitionParser.cpp.

References Mantid::Kernel::V3D::angle(), Mantid::Kernel::V3D::cross_prod(), Mantid::Geometry::IComponent::getPos(), Mantid::Geometry::IComponent::getRotation(), Mantid::Kernel::Quat::inverse(), Mantid::Kernel::V3D::norm(), Mantid::Kernel::normalize(), Mantid::Geometry::IComponent::rotate(), Mantid::Kernel::Quat::rotate(), and Mantid::Geometry::z.

◆ parseFacingElementToV3D()

Kernel::V3D Mantid::Geometry::InstrumentDefinitionParser::parseFacingElementToV3D ( Poco::XML::Element *  pElem)
private

Parse position of facing element to V3D.

Parameters
pElem:: Facing type element to parse
Returns
Return parsed position as a V3D

Definition at line 1946 of file InstrumentDefinitionParser.cpp.

References attrToDouble(), m_angleConvertConst, Mantid::Kernel::V3D::spherical(), Mantid::Geometry::x, Mantid::Geometry::y, and Mantid::Geometry::z.

Referenced by readDefaults(), and setFacing().

◆ parseLocationsForEachTopLevelComponent()

void Mantid::Geometry::InstrumentDefinitionParser::parseLocationsForEachTopLevelComponent ( Kernel::ProgressBase progressReporter,
const std::string &  filename,
const std::vector< Poco::XML::Element * > &  compElems 
)
private

Aggregate locations and IDs for components.

Parameters
progressReporter:: A progress reporter
filename:: Name of the IDF, for exception message
compElems:: Vector of pointers for component elements

Definition at line 322 of file InstrumentDefinitionParser.cpp.

References appendAssembly(), appendLeaf(), appendLocations(), checkComponentContainsLocationElement(), checkIdListExistsAndDefinesEnoughIDs(), isAssembly(), m_instrument, Mantid::Kernel::ProgressBase::report(), Mantid::Geometry::InstrumentDefinitionParser::IdList::reset(), and Mantid::Kernel::ProgressBase::resetNumSteps().

Referenced by parseXML().

◆ parsePosition()

V3D Mantid::Geometry::InstrumentDefinitionParser::parsePosition ( Poco::XML::Element *  pElem)
private

Get position coordinates from XML element.

Parameters
pElem:: XML element whose attributes contain position coordinates
Returns
Position coordinates in the form of a V3D object

Definition at line 2983 of file InstrumentDefinitionParser.cpp.

References attrToDouble(), Mantid::Kernel::V3D::spherical(), Mantid::Geometry::x, Mantid::Geometry::y, and Mantid::Geometry::z.

Referenced by translateRotateXMLcuboid().

◆ parseXML()

Instrument_sptr Mantid::Geometry::InstrumentDefinitionParser::parseXML ( Kernel::ProgressBase progressReporter)

◆ populateIdList()

void Mantid::Geometry::InstrumentDefinitionParser::populateIdList ( Poco::XML::Element *  pE,
IdList idList 
)
private

Method for populating IdList.

Parameters
pE:: Poco::XML element that points to an <idlist>
idList:: The structure to populate with detector ID numbers
Exceptions
logic_errorThrown if argument is not a child of component element
InstrumentDefinitionErrorThrown if issues with the content of XML instrument file

Definition at line 1738 of file InstrumentDefinitionParser.cpp.

References Mantid::Kernel::Logger::error(), Mantid::Geometry::g_log, Mantid::Geometry::InstrumentDefinitionParser::IdList::idname, m_xmlFile, and Mantid::Geometry::InstrumentDefinitionParser::IdList::vec.

Referenced by appendAssembly(), and appendLeaf().

◆ readDefaults()

void Mantid::Geometry::InstrumentDefinitionParser::readDefaults ( Poco::XML::Element *  defaults)
private

Reads the contents of the <defaults> element to set member variables,.

Reads the contents of the <defaults> element to set member variables, requires m_instrument to be already set.

Parameters
defaults:: points to the data read from the <defaults> element, can be null.

Definition at line 945 of file InstrumentDefinitionParser.cpp.

References Mantid::Geometry::axisNameToAxisType(), Mantid::Geometry::Left, m_angleConvertConst, m_defaultFacing, m_deltaOffsets, m_haveDefaultFacing, m_indirectPositions, m_instrument, parseFacingElementToV3D(), and Mantid::Geometry::Right.

Referenced by parseXML().

◆ saveDOM_Tree()

void Mantid::Geometry::InstrumentDefinitionParser::saveDOM_Tree ( std::string &  outFilename)

Save DOM tree to xml file.

This method was initially added for testing purpose but may be useful for other purposes. During the parsing of the DOM tree in parseXML() the tree may be modified, e.g. if <combine-components-into-one-shape> is used.

Parameters
outFilename:: Output filename

Definition at line 589 of file InstrumentDefinitionParser.cpp.

References getDocument().

◆ setComponentLinks()

void Mantid::Geometry::InstrumentDefinitionParser::setComponentLinks ( std::shared_ptr< Geometry::Instrument > &  instrument,
Poco::XML::Element *  pRootElem,
Kernel::ProgressBase progress = nullptr,
const std::string &  requestedDate = std::string() 
)

Add/overwrite any parameters specified in instrument with param values specified in <component-link> XML elements.

Apply parameters that may be specified in <component-link> XML elements.

Input variable pRootElem may e.g. be the root element of an XML parameter file or the root element of a IDF

Parameters
instrument:: Instrument
pRootElem:: Associated Poco::XML element that may contain <component-link> elements
progress:: Optional progress object for reporting progress to an algorithm
requestedDate:: Optional Date against which to check the validity of an IPF parameter

Definition at line 2371 of file InstrumentDefinitionParser.cpp.

References Mantid::Kernel::Logger::error(), Mantid::Geometry::g_log, Mantid::Kernel::ProgressBase::hasCancellationBeenRequested(), m_angleConvertConst, Mantid::Kernel::ProgressBase::report(), Mantid::Kernel::ProgressBase::resetNumSteps(), setLogfile(), and Mantid::Kernel::Logger::warning().

Referenced by Mantid::DataHandling::LoadParameterFile::exec(), and parseXML().

◆ setFacing()

void Mantid::Geometry::InstrumentDefinitionParser::setFacing ( Geometry::IComponent comp,
const Poco::XML::Element *  pElem 
)
private

Set facing of comp as specified in XML facing element.

Set facing of comp as specified in XML facing element (which must be sub-element of a location element).

Parameters
comp:: To set facing of
pElem:: Poco::XML element that points a <location> element, which optionally may be detached (meaning it is not required to be part of the DOM tree of the IDF)
Exceptions
logic_errorThrown if second argument is not a pointer to a 'location' XML element

Definition at line 1989 of file InstrumentDefinitionParser.cpp.

References attrToDouble(), Mantid::Kernel::Logger::error(), Mantid::Geometry::g_log, m_angleConvertConst, m_defaultFacing, m_haveDefaultFacing, makeXYplaneFaceComponent(), parseFacingElementToV3D(), and Mantid::Geometry::IComponent::rotate().

Referenced by appendAssembly(), appendLeaf(), createDetectorOrMonitor(), createGridDetector(), and createRectangularDetector().

◆ setLocation()

void Mantid::Geometry::InstrumentDefinitionParser::setLocation ( Geometry::IComponent comp,
const Poco::XML::Element *  pElem,
const double  angleConvertConst,
const bool  deltaOffsets = false 
)
private

Set location (position) of comp as specified in XML location element.

Parameters
comp:: To set position/location off
pElem:: Poco::XML element that points a <location> element, which optionally may be detached (meaning it is not required to be part of the DOM tree of the IDF)
angleConvertConst:: constant for converting deg to rad
deltaOffsets:: radial position offsets
Exceptions
logic_errorThrown if second argument is not a pointer to a 'location' XML element

Definition at line 631 of file InstrumentDefinitionParser.cpp.

References attrToDouble(), Mantid::Geometry::CompAssembly::getPos(), getRelativeTranslation(), Mantid::Geometry::IComponent::getRotation(), Mantid::Geometry::IComponent::rotate(), Mantid::Geometry::Component::setParent(), Mantid::Geometry::Component::setPos(), Mantid::Geometry::IComponent::setPos(), Mantid::Geometry::Component::setRot(), and Mantid::Geometry::IComponent::translate().

Referenced by adjust(), appendAssembly(), appendLeaf(), createDetectorOrMonitor(), createGridDetector(), createNeutronicInstrument(), createRectangularDetector(), createStructuredDetector(), and getShapeCoorSysComp().

◆ setLogfile()

void Mantid::Geometry::InstrumentDefinitionParser::setLogfile ( const Geometry::IComponent comp,
const Poco::XML::Element *  pElem,
InstrumentParameterCache logfileCache,
const std::string &  requestedDate = std::string() 
)
private

Set parameter/logfile info (if any) associated with component.

Parameters
comp:: Some component
pElem:: Poco::XML element that may hold <parameter> elements
logfileCache:: Cache to add information about parameter to
requestedDate:: Reference date to check the validity of the parameter against
Exceptions
InstrumentDefinitionErrorThrown if issues with the content of XML instrument file

Definition at line 2044 of file InstrumentDefinitionParser.cpp.

References attrToDouble(), Mantid::Kernel::Logger::error(), Mantid::Geometry::g_log, Mantid::Geometry::IComponent::getName(), index, Mantid::Kernel::SingletonHolder< T >::Instance(), m_angleConvertConst, m_hasParameterElement, m_hasParameterElement_beenSet, m_xmlFile, value, Mantid::Kernel::Logger::warning(), Mantid::Geometry::x, and Mantid::Geometry::y.

Referenced by appendAssembly(), appendLeaf(), createDetectorOrMonitor(), createGridDetector(), createRectangularDetector(), createStructuredDetector(), parseXML(), and setComponentLinks().

◆ setupGeometryCache()

InstrumentDefinitionParser::CachingOption Mantid::Geometry::InstrumentDefinitionParser::setupGeometryCache ( )
private

Reads in or creates the geometry cache ('vtp') file.

Returns
CachingOption selected.

Definition at line 2532 of file InstrumentDefinitionParser.cpp.

References applyCache(), getMangledName(), Mantid::Kernel::SingletonHolder< T >::Instance(), m_cacheFile, NoneApplied, ReadFallBack, ReadGeomCache, and writeAndApplyCache().

Referenced by parseXML().

◆ setValidityRange()

void Mantid::Geometry::InstrumentDefinitionParser::setValidityRange ( const Poco::XML::Element *  pRootElem)
private

Check the validity range and add it to the instrument object.

Checks the validity range in the IDF and adds it to the instrument object.

Parameters
pRootElemA pointer to the root element of the instrument definition

Definition at line 890 of file InstrumentDefinitionParser.cpp.

References Mantid::Geometry::d, m_instrument, and m_xmlFile.

Referenced by parseXML().

◆ throwIfTypeNameNotUnique()

void Mantid::Geometry::InstrumentDefinitionParser::throwIfTypeNameNotUnique ( const std::string &  filename,
const std::string &  typeName 
) const
private

Throw exception if type name is not unique in the IDF.

Type names in the IDF must be unique.

Throw an exception if this one is not.

Parameters
filename:: Filename of the IDF, for the exception message
typeName:: Name of the type being checked

Definition at line 197 of file InstrumentDefinitionParser.cpp.

References Mantid::Kernel::Logger::error(), Mantid::Geometry::g_log, and getTypeElement.

Referenced by adjustTypesContainingCombineComponentsElement(), and collateTypeInformation().

◆ translateRotateXMLcuboid() [1/2]

std::string Mantid::Geometry::InstrumentDefinitionParser::translateRotateXMLcuboid ( Geometry::ICompAssembly comp,
const Poco::XML::Element *  cuboidEle,
const std::string &  cuboidName 
)
private

Returns a translated and rotated <cuboid> element.

Returns a translated and rotated <cuboid> element with "id" attribute equal cuboidName.

Parameters
compcoordinate system to translate and rotate cuboid to
cuboidEleInput <cuboid> element
cuboidNameWhat the "id" attribute of the returned <coboid> will be set to
Returns
XML string of translated and rotated <cuboid>

Definition at line 2735 of file InstrumentDefinitionParser.cpp.

References getAbsolutPositionInCompCoorSys(), getShapeElement(), parsePosition(), Mantid::Kernel::V3D::X(), Mantid::Kernel::V3D::Y(), and Mantid::Kernel::V3D::Z().

Referenced by adjust(), and translateRotateXMLcuboid().

◆ translateRotateXMLcuboid() [2/2]

std::string Mantid::Geometry::InstrumentDefinitionParser::translateRotateXMLcuboid ( Geometry::ICompAssembly comp,
const std::string &  cuboidXML,
const std::string &  cuboidName 
)
private

Returns a translated and rotated <cuboid> element.

Returns a translated and rotated <cuboid> element with "id" attribute equal cuboidName.

Parameters
compcoordinate system to translate and rotate cuboid to
cuboidXMLInput <cuboid> xml string
cuboidNameWhat the "id" attribute of the returned <coboid> will be set to
Returns
XML string of translated and rotated <cuboid>

Definition at line 2807 of file InstrumentDefinitionParser.cpp.

References translateRotateXMLcuboid().

◆ writeAndApplyCache()

InstrumentDefinitionParser::CachingOption Mantid::Geometry::InstrumentDefinitionParser::writeAndApplyCache ( IDFObject_const_sptr  firstChoiceCache,
IDFObject_const_sptr  fallBackCache 
)
private

Write out a cache file.

Write the cache file from the IDF file and apply it.

Parameters
firstChoiceCache: File location for a first choice cache.
fallBackCache: File location for a fallback cache if required.

Definition at line 2493 of file InstrumentDefinitionParser.cpp.

References Mantid::Kernel::Logger::error(), Mantid::Geometry::g_log, Mantid::Kernel::Logger::information(), mapTypeNameToShape, Mantid::Kernel::Logger::notice(), WroteCacheTemp, and WroteGeomCache.

Referenced by setupGeometryCache().

Member Data Documentation

◆ getTypeElement

std::map<std::string, Poco::XML::Element *> Mantid::Geometry::InstrumentDefinitionParser::getTypeElement
private

map which holds names of types and pointers to these type for fast retrieval in code

Definition at line 311 of file InstrumentDefinitionParser.h.

Referenced by adjust(), adjustTypesContainingCombineComponentsElement(), appendAssembly(), appendLeaf(), collateTypeInformation(), getShapeCoorSysComp(), and throwIfTypeNameNotUnique().

◆ isTypeAssembly

std::map<std::string, bool> Mantid::Geometry::InstrumentDefinitionParser::isTypeAssembly
private

map which holds names of types and whether or not they are categorized as being assemblies, which means whether the type element contains component elements

Definition at line 298 of file InstrumentDefinitionParser.h.

Referenced by adjust(), adjustTypesContainingCombineComponentsElement(), createShapeIfTypeIsNotAnAssembly(), and isAssembly().

◆ m_angleConvertConst

double Mantid::Geometry::InstrumentDefinitionParser::m_angleConvertConst
private

when this const equals 1 it means that angle=degree (default) is set in IDF otherwise if this const equals 180/pi it means that angle=radian is set in IDF

Definition at line 325 of file InstrumentDefinitionParser.h.

Referenced by adjust(), appendAssembly(), appendLeaf(), createDetectorOrMonitor(), createGridDetector(), createNeutronicInstrument(), createRectangularDetector(), createStructuredDetector(), getShapeCoorSysComp(), parseFacingElementToV3D(), readDefaults(), setComponentLinks(), setFacing(), and setLogfile().

◆ m_cacheFile

IDFObject_const_sptr Mantid::Geometry::InstrumentDefinitionParser::m_cacheFile
private

Input vtp file.

Definition at line 273 of file InstrumentDefinitionParser.h.

Referenced by initialise(), InstrumentDefinitionParser(), and setupGeometryCache().

◆ m_cachingOption

CachingOption Mantid::Geometry::InstrumentDefinitionParser::m_cachingOption
private

Caching applied.

Definition at line 350 of file InstrumentDefinitionParser.h.

Referenced by getAppliedCachingOption(), and parseXML().

◆ m_defaultFacing

Kernel::V3D Mantid::Geometry::InstrumentDefinitionParser::m_defaultFacing
private

Hold default facing position.

Definition at line 308 of file InstrumentDefinitionParser.h.

Referenced by createGridDetector(), createRectangularDetector(), createStructuredDetector(), readDefaults(), and setFacing().

◆ m_deltaOffsets

bool Mantid::Geometry::InstrumentDefinitionParser::m_deltaOffsets
private

Flag to indicate whether offsets given in spherical coordinates are to be added to the current position (true) or are a vector from the current position (false, default)

Definition at line 319 of file InstrumentDefinitionParser.h.

Referenced by appendAssembly(), appendLeaf(), createDetectorOrMonitor(), createGridDetector(), createNeutronicInstrument(), createRectangularDetector(), createStructuredDetector(), and readDefaults().

◆ m_facingComponent

std::vector<Geometry::ObjComponent *> Mantid::Geometry::InstrumentDefinitionParser::m_facingComponent
private

Container to hold all detectors and monitors added to the instrument.

Used for 'facing' these to component specified under <defaults>. NOTE: Seems unused, ever.

Definition at line 304 of file InstrumentDefinitionParser.h.

Referenced by createDetectorOrMonitor().

◆ m_hasParameterElement

std::vector<Poco::XML::Element *> Mantid::Geometry::InstrumentDefinitionParser::m_hasParameterElement
private

Holds all the xml elements that have a <parameter> child element.

Added purely for the purpose of computing speed and is used in setLogFile() for the purpose of quickly accessing if a component have a parameter/logfile associated with it or not

  • instead of using the comparatively slow poco call getElementsByTagName() (or getChildElement)

Definition at line 289 of file InstrumentDefinitionParser.h.

Referenced by createVectorOfElementsContainingAParameterElement(), and setLogfile().

◆ m_hasParameterElement_beenSet

bool Mantid::Geometry::InstrumentDefinitionParser::m_hasParameterElement_beenSet
private

has m_hasParameterElement been set - used when public method setComponentLinks is used

Definition at line 292 of file InstrumentDefinitionParser.h.

Referenced by createVectorOfElementsContainingAParameterElement(), and setLogfile().

◆ m_haveDefaultFacing

bool Mantid::Geometry::InstrumentDefinitionParser::m_haveDefaultFacing
private

True if defaults->components-are-facing is set in instrument def. file.

Definition at line 306 of file InstrumentDefinitionParser.h.

Referenced by createGridDetector(), createRectangularDetector(), createStructuredDetector(), readDefaults(), and setFacing().

◆ m_indirectPositions

bool Mantid::Geometry::InstrumentDefinitionParser::m_indirectPositions
private

Flag to indicate whether IDF contains physical & neutronic positions.

Definition at line 327 of file InstrumentDefinitionParser.h.

Referenced by appendAssembly(), createDetectorOrMonitor(), parseXML(), and readDefaults().

◆ m_instName

std::string Mantid::Geometry::InstrumentDefinitionParser::m_instName
private

Name of the instrument.

Definition at line 276 of file InstrumentDefinitionParser.h.

Referenced by getMangledName(), and initialise().

◆ m_instrument

std::shared_ptr<Geometry::Instrument> Mantid::Geometry::InstrumentDefinitionParser::m_instrument
private

◆ m_neutronicPos

std::map<Geometry::IComponent *, Poco::XML::Element *> Mantid::Geometry::InstrumentDefinitionParser::m_neutronicPos
private

A map containing the neutronic position for each detector.

Used when m_indirectPositions is true.

Definition at line 331 of file InstrumentDefinitionParser.h.

Referenced by appendAssembly(), createDetectorOrMonitor(), and createNeutronicInstrument().

◆ m_pDoc

Poco::AutoPtr<Poco::XML::Document> Mantid::Geometry::InstrumentDefinitionParser::m_pDoc
private

XML document is lazy loaded.

Definition at line 279 of file InstrumentDefinitionParser.h.

Referenced by getDocument().

◆ m_tempPosHolder

std::map<const Geometry::IComponent *, SphVec> Mantid::Geometry::InstrumentDefinitionParser::m_tempPosHolder
private

Map to store positions of parent components in spherical coordinates.

Definition at line 347 of file InstrumentDefinitionParser.h.

Referenced by getRelativeTranslation(), and parseXML().

◆ m_xmlFile

IDFObject_const_sptr Mantid::Geometry::InstrumentDefinitionParser::m_xmlFile
private

◆ mapTypeNameToShape

std::map<std::string, std::shared_ptr<Geometry::IObject> > Mantid::Geometry::InstrumentDefinitionParser::mapTypeNameToShape
private

The documentation for this class was generated from the following files: