diff --git a/Framework/Beamline/inc/MantidBeamline/ComponentType.h b/Framework/Beamline/inc/MantidBeamline/ComponentType.h index 9548fac56244a43b907f5b23df7afe5c59c72efc..c5e33293a06915eef466511ce25289f9311aa010 100644 --- a/Framework/Beamline/inc/MantidBeamline/ComponentType.h +++ b/Framework/Beamline/inc/MantidBeamline/ComponentType.h @@ -6,6 +6,7 @@ namespace Mantid { namespace Beamline { enum class ComponentType { Generic, + Infinite, Rectangular, Structured, Unstructured, diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/ComponentVisitor.h b/Framework/Geometry/inc/MantidGeometry/Instrument/ComponentVisitor.h index 1ee03f9ba9eb327e1264fc3234da2d7b6e63756b..caa2b19eb069a58dde27cc125bce06e48d3b695c 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/ComponentVisitor.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/ComponentVisitor.h @@ -43,7 +43,11 @@ public: virtual size_t registerComponentAssembly(const ICompAssembly &assembly) = 0; virtual size_t registerGenericComponent(const IComponent &component) = 0; virtual size_t + registerInfiniteComponent(const Mantid::Geometry::IComponent &component) = 0; + virtual size_t registerGenericObjComponent(const IObjComponent &objComponent) = 0; + virtual size_t + registerInfiniteObjComponent(const IObjComponent &component) = 0; virtual size_t registerDetector(const IDetector &detector) = 0; virtual size_t registerStructuredBank(const ICompAssembly &bank) = 0; virtual size_t registerObjComponentAssembly(const ObjCompAssembly &obj) = 0; diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/InstrumentVisitor.h b/Framework/Geometry/inc/MantidGeometry/Instrument/InstrumentVisitor.h index f228a8b30797ccbccea3cd2f2425f778e98cd61d..a6a365bbc84aff552b37948397ac061f61633323 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/InstrumentVisitor.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/InstrumentVisitor.h @@ -168,9 +168,15 @@ public: virtual size_t registerGenericComponent( const Mantid::Geometry::IComponent &component) override; + virtual size_t registerInfiniteComponent( + const Mantid::Geometry::IComponent &component) override; + virtual size_t registerGenericObjComponent( const Mantid::Geometry::IObjComponent &objComponent) override; + virtual size_t + registerInfiniteObjComponent(const IObjComponent &objComponent) override; + virtual size_t registerStructuredBank(const Mantid::Geometry::ICompAssembly &bank) override; diff --git a/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h b/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h index e6b3441895544ab6b4243c45a371d76192d7f67a..a8ea0b2ae7d5981c1d5d8d2ef7519583e9b54690 100644 --- a/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h +++ b/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h @@ -83,6 +83,11 @@ public: return obj; } + bool isFiniteGeometry() const override { return m_isFiniteGeometry; } + void setFiniteGeometryFlag(bool isFinite) override { + m_isFiniteGeometry = isFinite; + } + /// Return the top rule const Rule *topRule() const { return TopRule.get(); } void setID(const std::string &id) { m_id = id; } @@ -272,6 +277,8 @@ private: std::string m_id; /// material composition std::unique_ptr<Kernel::Material> m_material; + /// Whether or not the object geometry is finite + bool m_isFiniteGeometry = true; protected: std::vector<const Surface *> m_SurList; ///< Full surfaces (make a map diff --git a/Framework/Geometry/inc/MantidGeometry/Objects/IObject.h b/Framework/Geometry/inc/MantidGeometry/Objects/IObject.h index 3fc6c456a0754008590f25e8717073ba6f7cac5d..3567f7bb27c5792ec7f5bd07609b34acdf2e549c 100644 --- a/Framework/Geometry/inc/MantidGeometry/Objects/IObject.h +++ b/Framework/Geometry/inc/MantidGeometry/Objects/IObject.h @@ -59,6 +59,8 @@ public: virtual bool isOnSide(const Kernel::V3D &) const = 0; virtual int calcValidType(const Kernel::V3D &Pt, const Kernel::V3D &uVec) const = 0; + virtual bool isFiniteGeometry() const { return true; } + virtual void setFiniteGeometryFlag(bool) {} virtual bool hasValidShape() const = 0; virtual IObject *clone() const = 0; virtual IObject * diff --git a/Framework/Geometry/src/Instrument/ComponentInfo.cpp b/Framework/Geometry/src/Instrument/ComponentInfo.cpp index 8e6c0dbe9a476c1fa9385b90ee2b667a1a94fc7c..ad76cbcca0fda63c77152011a39a546243854163 100644 --- a/Framework/Geometry/src/Instrument/ComponentInfo.cpp +++ b/Framework/Geometry/src/Instrument/ComponentInfo.cpp @@ -392,7 +392,8 @@ BoundingBox ComponentInfo::componentBoundingBox(const size_t index, const BoundingBox *reference) const { // Check that we have a valid shape here - if (!hasValidShape(index)) { + if (!hasValidShape(index) || + componentType(index) == Beamline::ComponentType::Infinite) { return BoundingBox(); // Return null bounding box } const auto &s = this->shape(index); @@ -445,7 +446,8 @@ ComponentInfo::componentBoundingBox(const size_t index, */ BoundingBox ComponentInfo::boundingBox(const size_t componentIndex, const BoundingBox *reference) const { - if (isDetector(componentIndex)) { + if (isDetector(componentIndex) || + componentType(componentIndex) == Beamline::ComponentType::Infinite) { return componentBoundingBox(componentIndex, reference); } BoundingBox absoluteBB; diff --git a/Framework/Geometry/src/Instrument/InstrumentVisitor.cpp b/Framework/Geometry/src/Instrument/InstrumentVisitor.cpp index 48475106c4dad2601d5556cc9683d3eae5d601f0..d8bc94059ff6e9be3f689a85126c61fc111f9c0c 100644 --- a/Framework/Geometry/src/Instrument/InstrumentVisitor.cpp +++ b/Framework/Geometry/src/Instrument/InstrumentVisitor.cpp @@ -212,6 +212,35 @@ InstrumentVisitor::registerGenericComponent(const IComponent &component) { return componentIndex; } +/** +* @brief InstrumentVisitor::registerInfiniteComponent +* @param component : IComponent being visited +* @return Component index of this component +*/ +size_t InstrumentVisitor::registerInfiniteComponent( + const Mantid::Geometry::IComponent &component) { + /* + * For a generic leaf component we extend the component ids list, but + * the detector indexes entries will of course be empty + */ + m_detectorRanges->emplace_back( + std::make_pair(0, 0)); // Represents an empty range + // Record the ID -> index mapping + const size_t componentIndex = commonRegistration(component); + m_componentType->push_back(Beamline::ComponentType::Infinite); + + const size_t componentStart = m_assemblySortedComponentIndices->size(); + m_componentRanges->emplace_back( + std::make_pair(componentStart, componentStart + 1)); + m_assemblySortedComponentIndices->push_back(componentIndex); + // Unless this is the root component this parent is not correct and will be + // updated later in the register call of the parent. + m_parentComponentIndices->push_back(componentIndex); + // Generic components are not assemblies and do not therefore have children. + m_children->emplace_back(std::vector<size_t>()); + return componentIndex; +} + /** * @brief InstrumentVisitor::registerGenericObjComponent * @param objComponent : IObjComponent being visited @@ -224,6 +253,18 @@ size_t InstrumentVisitor::registerGenericObjComponent( return index; } +/** +* @brief InstrumentVisitor::registerInfiniteObjComponent +* @param objComponent : IObjComponent being visited +* @return Component index of this component +*/ +size_t InstrumentVisitor::registerInfiniteObjComponent( + const IObjComponent &objComponent) { + auto index = registerInfiniteComponent(objComponent); + (*m_shapes)[index] = objComponent.shape(); + return index; +} + /** * Register a structured bank * @param bank : Rectangular Detector diff --git a/Framework/Geometry/src/Instrument/ObjComponent.cpp b/Framework/Geometry/src/Instrument/ObjComponent.cpp index 24f04ae6113631722ecbbc6b3813ad105597aa37..3b66913192396604f2e6af71f5371900d4934fe0 100644 --- a/Framework/Geometry/src/Instrument/ObjComponent.cpp +++ b/Framework/Geometry/src/Instrument/ObjComponent.cpp @@ -1,12 +1,13 @@ #include "MantidGeometry/Instrument/ObjComponent.h" -#include "MantidGeometry/Instrument/ComponentVisitor.h" #include "MantidGeometry/Instrument/ComponentInfo.h" -#include "MantidGeometry/Objects/IObject.h" +#include "MantidGeometry/Instrument/ComponentVisitor.h" #include "MantidGeometry/Objects/BoundingBox.h" +#include "MantidGeometry/Objects/CSGObject.h" +#include "MantidGeometry/Objects/IObject.h" #include "MantidGeometry/Objects/Track.h" +#include "MantidGeometry/Rendering/GeometryHandler.h" #include "MantidKernel/Exception.h" #include "MantidKernel/Material.h" -#include "MantidGeometry/Rendering/GeometryHandler.h" #include <cfloat> namespace Mantid { @@ -342,8 +343,10 @@ void ObjComponent::initDraw() const { */ size_t ObjComponent::registerContents(class ComponentVisitor &componentVisitor) const { - - return componentVisitor.registerGenericObjComponent(*this); + if (this->shape()->isFiniteGeometry()) + return componentVisitor.registerGenericObjComponent(*this); + else + return componentVisitor.registerInfiniteObjComponent(*this); } } // namespace Geometry diff --git a/Framework/Geometry/src/Objects/ShapeFactory.cpp b/Framework/Geometry/src/Objects/ShapeFactory.cpp index c34fd71288670e6a2b21e22189294516891ff493..439fb17c8956ccd1f2a71605d5d197384b931e7c 100644 --- a/Framework/Geometry/src/Objects/ShapeFactory.cpp +++ b/Framework/Geometry/src/Objects/ShapeFactory.cpp @@ -152,10 +152,12 @@ ShapeFactory::createShape(Poco::XML::Element *pElem) { numPrimitives++; } else if (primitiveName == "infinite-plane") { idMatching[idFromUser] = parseInfinitePlane(pE, primitives, l_id); + retVal->setFiniteGeometryFlag(false); numPrimitives++; } else if (primitiveName == "infinite-cylinder") { idMatching[idFromUser] = parseInfiniteCylinder(pE, primitives, l_id); + retVal->setFiniteGeometryFlag(false); numPrimitives++; } else if (primitiveName == "cylinder") { lastElement = pE; @@ -175,6 +177,7 @@ ShapeFactory::createShape(Poco::XML::Element *pElem) { numPrimitives++; } else if (primitiveName == "infinite-cone") { idMatching[idFromUser] = parseInfiniteCone(pE, primitives, l_id); + retVal->setFiniteGeometryFlag(false); numPrimitives++; } else if (primitiveName == "cone") { lastElement = pE; diff --git a/qt/widgets/instrumentview/src/InstrumentActor.cpp b/qt/widgets/instrumentview/src/InstrumentActor.cpp index 59422c7bb561871c98fc866edde906cc861e80e8..e304b6b59e9bb591d57b3c864fc0b60600bc3142 100644 --- a/qt/widgets/instrumentview/src/InstrumentActor.cpp +++ b/qt/widgets/instrumentview/src/InstrumentActor.cpp @@ -728,8 +728,10 @@ void InstrumentActor::draw(bool picking) const { void InstrumentActor::doDraw(bool picking) const { const auto &compInfo = componentInfo(); for (size_t i = 0; i < compInfo.size(); ++i) { + auto type = compInfo.componentType(i); if ((!compInfo.isDetector(i) && !m_showGuides) || - compInfo.componentType(i) == Beamline::ComponentType::OutlineComposite) + type == Beamline::ComponentType::OutlineComposite || + type == Beamline::ComponentType::Infinite) continue; if (compInfo.hasValidShape(i)) {