Skip to content
Snippets Groups Projects
Commit 80b33d08 authored by Nicholas Styles's avatar Nicholas Styles
Browse files

Allow duplication of GeoAlignableTransforms for alignable elements

parent c8364ca3
No related branches found
No related tags found
1 merge request!397Allow duplication of GeoAlignableTransforms for alignable elements
Pipeline #9896830 passed
......@@ -32,7 +32,7 @@ class Element2GeoItem: public GeoDeDuplicator {
public:
Element2GeoItem() = default;
virtual ~Element2GeoItem() = default;
GeoIntrusivePtr<RCBase> process(const xercesc::DOMElement *element, GmxUtil &gmxUtil);
GeoIntrusivePtr<RCBase> process(const xercesc::DOMElement *element, GmxUtil &gmxUtil, const bool &allowDuplication=false);
virtual GeoIntrusivePtr<RCBase> make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
protected:
using EntryMap = std::map<std::string, GeoIntrusivePtr<RCBase>>;
......
......@@ -18,7 +18,7 @@ using namespace std;
using namespace xercesc;
GeoIntrusivePtr<RCBase> Element2GeoItem::process(const xercesc::DOMElement *element, GmxUtil &gmxUtil) {
GeoIntrusivePtr<RCBase> Element2GeoItem::process(const xercesc::DOMElement *element, GmxUtil &gmxUtil, const bool &allowDuplication) {
char *name2release;
XMLCh * name_tmp = XMLString::transcode("name");
......@@ -30,7 +30,7 @@ GeoIntrusivePtr<RCBase> Element2GeoItem::process(const xercesc::DOMElement *elem
GeoIntrusivePtr<RCBase> item{nullptr};
EntryMap::iterator entry;
if (name.empty()) { // Unnamed item; cannot store in the map; make a new one
if (name.empty() || allowDuplication) { // Unnamed item or an item that can be duplicated; cannot store in the map; make a new one
item = make(element, gmxUtil);
} else if ((entry = m_map.find(name)) == m_map.end()) { // Not in; make a new one
item = make(element, gmxUtil);
......
......@@ -39,7 +39,7 @@ void TransformProcessor::process(const DOMElement *element, GmxUtil &gmxUtil, Ge
XMLCh * alignable_tmp;
alignable_tmp = XMLString::transcode("alignable");
bool alignable = element->hasAttribute(alignable_tmp);
const bool alignable = element->hasAttribute(alignable_tmp);
//
// Do second element first, to find what sort of transform is needed (shape or logvol etc.?)
//
......@@ -57,8 +57,11 @@ void TransformProcessor::process(const DOMElement *element, GmxUtil &gmxUtil, Ge
tagName = XMLString::transcode(transformation->getTagName()); // transformation or transformationref
// TODO: ******* Should check here that an alignable transform is given an alignable transformation and object; to be done
// If alignable is true, this is passed on to Element2GeoItem::process in order to allow multiple transforms to be created with the same name
// This is necessary because we need an AlignableTransform for each element we want to align, even if the initial transform is identical.
// Without this, the de-duplication will return an already-exisiting transform if one already exists with that name
toAdd.push_back(dynamic_pointer_cast<GeoGraphNode>(gmxUtil.geoItemRegistry.find(string(tagName))->process(transformation, gmxUtil)));
toAdd.push_back(dynamic_pointer_cast<GeoGraphNode>(gmxUtil.geoItemRegistry.find(string(tagName))->process(transformation, gmxUtil, alignable)));
XMLString::release(&tagName);
//
// Add transformation to DetectorManager via GmxInterface, if it is alignable
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment