Mantid
Loading...
Searching...
No Matches
GeometryHandler.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2008 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9#include "MantidGeometry/DllConfig.h"
12#include "MantidKernel/Logger.h"
13#include "MantidKernel/V3D.h"
14
15#include <memory>
16#include <vector>
17
18namespace Mantid {
19
20namespace Geometry {
21class IObjComponent;
22class CSGObject;
23class MeshObject2D;
24class MeshObject;
25namespace detail {
26class Renderer;
27class GeometryTriangulator;
28
29template <typename Adaptee> std::unique_ptr<Geometry::RenderingMesh> makeRenderingMesh(const Adaptee &adaptee) {
30
31 // Local class adapter
32 class Adapter : public Geometry::RenderingMesh {
33 private:
34 // Not owned but can be guraranteed not null
35 const Adaptee &m_adaptee;
36
37 public:
38 Adapter(const Adaptee &adaptee) : m_adaptee(adaptee) {}
39 size_t numberOfVertices() const override { return m_adaptee.numberOfVertices(); }
40 size_t numberOfTriangles() const override { return m_adaptee.numberOfTriangles(); }
41 std::vector<double> getVertices() const override { return m_adaptee.getVertices(); }
42 std::vector<uint32_t> getTriangles() const override { return m_adaptee.getTriangles(); }
43 virtual ~Adapter() = default;
44 };
45 return std::make_unique<Adapter>(adaptee);
46}
47} // namespace detail
48
57class MANTID_GEOMETRY_DLL GeometryHandler {
58private:
60
61protected:
62 std::shared_ptr<detail::ShapeInfo> m_shapeInfo;
63 std::unique_ptr<detail::GeometryTriangulator> m_triangulator;
64 IObjComponent *m_objComp = nullptr;
65 CSGObject *m_csgObj = nullptr;
66public:
68 GeometryHandler(const std::shared_ptr<CSGObject> &obj);
71 GeometryHandler &operator=(const MeshObject &obj);
73 GeometryHandler &operator=(const MeshObject2D &obj);
74 GeometryHandler(const GeometryHandler &handler);
75 GeometryHandler &operator=(GeometryHandler handler);
76 std::shared_ptr<GeometryHandler> clone() const;
78 void render() const;
79 void initialize() const;
80 bool canTriangulate() const { return !(m_triangulator == nullptr); }
82 size_t numberOfTriangles() const;
84 size_t numberOfPoints() const;
85
86 bool hasShapeInfo() const { return !(m_shapeInfo == nullptr); }
87 const detail::ShapeInfo &shapeInfo() const { return *m_shapeInfo; }
89 const std::vector<double> &getTriangleVertices() const;
91 const std::vector<uint32_t> &getTriangleFaces() const;
93 void setGeometryCache(size_t nPts, size_t nFaces, std::vector<double> &&pts, std::vector<uint32_t> &&faces);
96 void GetObjectGeom(detail::ShapeInfo::GeometryShape &type, std::vector<Kernel::V3D> &vector, double &innerRadius,
97 double &radius, double &height) const;
98 void setShapeInfo(detail::ShapeInfo &&shapeInfo);
99};
100
101} // NAMESPACE Geometry
102} // NAMESPACE Mantid
double height
Definition: GetAllEi.cpp:155
double radius
Definition: Rasterize.cpp:31
double innerRadius
Definition: Rasterize.cpp:39
double obj
the value of the quadratic function
Constructive Solid Geometry object.
Definition: CSGObject.h:51
Handles rendering of all object Geometry.
std::unique_ptr< detail::GeometryTriangulator > m_triangulator
static Kernel::Logger & PLog
The official logger.
std::shared_ptr< detail::ShapeInfo > m_shapeInfo
const detail::ShapeInfo & shapeInfo() const
Object Component class, this class brings together the physical attributes of the component to the po...
Definition: IObjComponent.h:37
Triangular Mesh Object.
Definition: MeshObject.h:50
RenderingMesh : Mesh abstraction required for rendering.
Definition: RenderingMesh.h:17
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition: Logger.h:52
std::unique_ptr< Geometry::RenderingMesh > makeRenderingMesh(const Adaptee &adaptee)
Helper class which provides the Collimation Length for SANS instruments.