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

MeshObject2D : More...

#include <MeshObject2D.h>

Inheritance diagram for Mantid::Geometry::MeshObject2D:
Mantid::Geometry::IObject

Classes

struct  PlaneParameters
 

Public Member Functions

MeshObject2Dclone () const override
 
MeshObject2DcloneWithMaterial (const Kernel::Material &material) const override
 
double distance (const Geometry::Track &ut) const override
 Compute the distance to the first point of intersection with the mesh. More...
 
double distanceToPlane (const Kernel::V3D &point) const
 
void draw () const override
 
boost::optional< Kernel::V3DgeneratePointInObject (Kernel::PseudoRandomNumberGenerator &rng, const BoundingBox &activeRegion, const size_t) const override
 
boost::optional< Kernel::V3DgeneratePointInObject (Kernel::PseudoRandomNumberGenerator &rng, const size_t) const override
 
const BoundingBoxgetBoundingBox () const override
 Returns an axis-aligned bounding box that will fit the shape. More...
 
void getBoundingBox (double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) const override
 Calculate (or return cached value of) Axis Aligned Bounding box (DEPRECATED) More...
 
std::shared_ptr< GeometryHandlergetGeometryHandler () const override
 
int getName () const override
 
void GetObjectGeom (detail::ShapeInfo::GeometryShape &type, std::vector< Kernel::V3D > &vectors, double &innerRadius, double &radius, double &height) const override
 
int getPointInObject (Kernel::V3D &point) const override
 Try to find a point that lies within (or on) the object. More...
 
std::vector< uint32_t > getTriangles () const
 
std::vector< double > getVertices () const
 
bool hasValidShape () const override
 
const std::string & id () const override
 
void initDraw () const override
 
int interceptSurface (Geometry::Track &ut) const override
 Given a track, fill the track with valid section. More...
 
bool isOnSide (const Kernel::V3D &) const override
 Determine if point is on the side of the object. More...
 
bool isValid (const Kernel::V3D &point) const override
 Check if a point is inside. More...
 
const Kernel::Materialmaterial () const override
 
 MeshObject2D (std::vector< uint32_t > &&faces, std::vector< Kernel::V3D > &&vertices, const Kernel::Material &&material)
 Constructor. More...
 
 MeshObject2D (std::vector< uint32_t > faces, std::vector< Kernel::V3D > vertices, const Kernel::Material &material)
 Constructor. More...
 
size_t numberOfTriangles () const
 
size_t numberOfVertices () const
 
bool operator== (const MeshObject2D &other) const
 
void setID (const std::string &id) override
 
virtual void setMaterial (const Kernel::Material &material) override
 
detail::ShapeInfo::GeometryShape shape () const override
 
const detail::ShapeInfoshapeInfo () const override
 
double solidAngle (const Kernel::V3D &observer) const override
 Solid angle only considers triangle facing sample. More...
 
double solidAngle (const Kernel::V3D &observer, const Kernel::V3D &scaleFactor) const override
 
double volume () const override
 
- Public Member Functions inherited from Mantid::Geometry::IObject
virtual IObjectclone () const =0
 
virtual IObjectcloneWithMaterial (const Kernel::Material &material) const =0
 
virtual double distance (const Geometry::Track &) const =0
 
virtual void draw () const =0
 
virtual boost::optional< Kernel::V3DgeneratePointInObject (Kernel::PseudoRandomNumberGenerator &rng, const BoundingBox &activeRegion, const size_t) const =0
 
virtual boost::optional< Kernel::V3DgeneratePointInObject (Kernel::PseudoRandomNumberGenerator &rng, const size_t) const =0
 
virtual const BoundingBoxgetBoundingBox () const =0
 Return cached value of axis-aligned bounding box. More...
 
virtual void getBoundingBox (double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) const =0
 Calculate (or return cached value of) Axis Aligned Bounding box (DEPRECATED) More...
 
virtual std::shared_ptr< GeometryHandlergetGeometryHandler () const =0
 
virtual int getName () const =0
 
virtual void GetObjectGeom (detail::ShapeInfo::GeometryShape &type, std::vector< Kernel::V3D > &vectors, double &innerRadius, double &radius, double &height) const =0
 
virtual int getPointInObject (Kernel::V3D &point) const =0
 
virtual bool hasValidShape () const =0
 
virtual const std::string & id () const =0
 
virtual void initDraw () const =0
 
virtual int interceptSurface (Geometry::Track &) const =0
 
virtual bool isFiniteGeometry () const
 
virtual bool isOnSide (const Kernel::V3D &) const =0
 
virtual bool isValid (const Kernel::V3D &) const =0
 
virtual const Kernel::Materialmaterial () const =0
 
virtual void setFiniteGeometryFlag (bool)
 
virtual void setID (const std::string &id)=0
 
virtual void setMaterial (const Kernel::Material &material)=0
 
virtual detail::ShapeInfo::GeometryShape shape () const =0
 
virtual const detail::ShapeInfoshapeInfo () const =0
 
virtual double solidAngle (const Kernel::V3D &observer) const =0
 
virtual double solidAngle (const Kernel::V3D &observer, const Kernel::V3D &scaleFactor) const =0
 
virtual double volume () const =0
 
virtual ~IObject ()=default
 

Static Public Member Functions

static bool pointsCoplanar (const std::vector< Kernel::V3D > &vertices)
 Estalish if points are coplanar. More...
 

Static Public Attributes

static const std::string Id = "MeshObject2D"
 Id as static. More...
 
static const double MinThickness = 0.001
 

Private Member Functions

void initialize ()
 Common initialization. More...
 

Private Attributes

BoundingBox m_boundingBox
 Bounding box. More...
 
std::shared_ptr< GeometryHandlerm_handler
 Geometry Handle for rendering. More...
 
std::string m_id
 optional string identifier More...
 
Kernel::Material m_material
 Material composition. More...
 
struct Mantid::Geometry::MeshObject2D::PlaneParameters m_planeParameters
 
std::vector< uint32_t > m_triangles
 Triangles are specified by indices into a list of vertices. More...
 
std::vector< Kernel::V3Dm_vertices
 Vertices. More...
 

Detailed Description

MeshObject2D :

Defines an IObject implemented as a 2D mesh composed of triangles. Avoids assumptions made in MeshObject to do with closed surfaces, non-zero volumes and assoicated additional runtime costs. The number of vertices is limited to 2^16 based on index type.

Definition at line 30 of file MeshObject2D.h.

Constructor & Destructor Documentation

◆ MeshObject2D() [1/2]

Mantid::Geometry::MeshObject2D::MeshObject2D ( std::vector< uint32_t >  faces,
std::vector< Kernel::V3D vertices,
const Kernel::Material material 
)

Constructor.

Definition at line 147 of file MeshObject2D.cpp.

References initialize().

◆ MeshObject2D() [2/2]

Mantid::Geometry::MeshObject2D::MeshObject2D ( std::vector< uint32_t > &&  faces,
std::vector< Kernel::V3D > &&  vertices,
const Kernel::Material &&  material 
)

Constructor.

Move constructor.

Definition at line 156 of file MeshObject2D.cpp.

References initialize().

Member Function Documentation

◆ clone()

MeshObject2D * Mantid::Geometry::MeshObject2D::clone ( ) const
overridevirtual

Implements Mantid::Geometry::IObject.

Definition at line 281 of file MeshObject2D.cpp.

References m_material, m_triangles, and m_vertices.

◆ cloneWithMaterial()

MeshObject2D * Mantid::Geometry::MeshObject2D::cloneWithMaterial ( const Kernel::Material material) const
overridevirtual

Implements Mantid::Geometry::IObject.

Definition at line 285 of file MeshObject2D.cpp.

References m_triangles, and m_vertices.

◆ distance()

double Mantid::Geometry::MeshObject2D::distance ( const Geometry::Track ut) const
overridevirtual

Compute the distance to the first point of intersection with the mesh.

Parameters
utTrack defining start/direction
Returns
The distance to the object
Exceptions
std::runtime_errorif no intersection was found

Implements Mantid::Geometry::IObject.

Definition at line 257 of file MeshObject2D.cpp.

References Mantid::Geometry::Track::direction(), Mantid::Geometry::intersection(), m_planeParameters, m_vertices, Mantid::Geometry::MeshObject2D::PlaneParameters::normal, Mantid::Geometry::MeshObject2D::PlaneParameters::p0, Mantid::Geometry::MeshObjectCommon::rayIntersectsTriangle(), Mantid::Kernel::V3D::scalar_prod(), and Mantid::Geometry::Track::startPoint().

◆ distanceToPlane()

double Mantid::Geometry::MeshObject2D::distanceToPlane ( const Kernel::V3D point) const

◆ draw()

void Mantid::Geometry::MeshObject2D::draw ( ) const
overridevirtual

Implements Mantid::Geometry::IObject.

Definition at line 413 of file MeshObject2D.cpp.

References m_handler.

◆ generatePointInObject() [1/2]

boost::optional< Kernel::V3D > Mantid::Geometry::MeshObject2D::generatePointInObject ( Kernel::PseudoRandomNumberGenerator rng,
const BoundingBox activeRegion,
const  size_t 
) const
overridevirtual

Implements Mantid::Geometry::IObject.

Definition at line 370 of file MeshObject2D.cpp.

◆ generatePointInObject() [2/2]

boost::optional< Kernel::V3D > Mantid::Geometry::MeshObject2D::generatePointInObject ( Kernel::PseudoRandomNumberGenerator rng,
const  size_t 
) const
overridevirtual

Implements Mantid::Geometry::IObject.

Definition at line 362 of file MeshObject2D.cpp.

◆ getBoundingBox() [1/2]

const BoundingBox & Mantid::Geometry::MeshObject2D::getBoundingBox ( ) const
overridevirtual

Returns an axis-aligned bounding box that will fit the shape.

This is not threadsafe

Returns
A reference to a bounding box for this shape.

Implements Mantid::Geometry::IObject.

Definition at line 346 of file MeshObject2D.cpp.

References Mantid::Geometry::MeshObjectCommon::getBoundingBox(), m_boundingBox, and m_vertices.

◆ getBoundingBox() [2/2]

void Mantid::Geometry::MeshObject2D::getBoundingBox ( double &  xmax,
double &  ymax,
double &  zmax,
double &  xmin,
double &  ymin,
double &  zmin 
) const
overridevirtual

Calculate (or return cached value of) Axis Aligned Bounding box (DEPRECATED)

Implements Mantid::Geometry::IObject.

Definition at line 350 of file MeshObject2D.cpp.

References Mantid::Geometry::MeshObjectCommon::getBoundingBox(), m_boundingBox, and m_vertices.

◆ getGeometryHandler()

std::shared_ptr< GeometryHandler > Mantid::Geometry::MeshObject2D::getGeometryHandler ( ) const
overridevirtual

Implements Mantid::Geometry::IObject.

Definition at line 389 of file MeshObject2D.cpp.

References m_handler.

◆ getName()

int Mantid::Geometry::MeshObject2D::getName ( ) const
overridevirtual

Implements Mantid::Geometry::IObject.

Definition at line 289 of file MeshObject2D.cpp.

◆ GetObjectGeom()

void Mantid::Geometry::MeshObject2D::GetObjectGeom ( detail::ShapeInfo::GeometryShape type,
std::vector< Kernel::V3D > &  vectors,
double &  innerRadius,
double &  radius,
double &  height 
) const
overridevirtual

Implements Mantid::Geometry::IObject.

Definition at line 408 of file MeshObject2D.cpp.

◆ getPointInObject()

int Mantid::Geometry::MeshObject2D::getPointInObject ( Kernel::V3D point) const
overridevirtual

Try to find a point that lies within (or on) the object.

Parameters
[out]point:: on exit set to the point value, if found
Returns
1 if point found, 0 otherwise

Implements Mantid::Geometry::IObject.

Definition at line 360 of file MeshObject2D.cpp.

References isValid().

◆ getTriangles()

std::vector< uint32_t > Mantid::Geometry::MeshObject2D::getTriangles ( ) const

Definition at line 397 of file MeshObject2D.cpp.

References m_triangles.

◆ getVertices()

std::vector< double > Mantid::Geometry::MeshObject2D::getVertices ( ) const

◆ hasValidShape()

bool Mantid::Geometry::MeshObject2D::hasValidShape ( ) const
overridevirtual

Implements Mantid::Geometry::IObject.

Definition at line 182 of file MeshObject2D.cpp.

References m_triangles, and m_vertices.

◆ id()

const std::string & Mantid::Geometry::MeshObject2D::id ( ) const
overridevirtual

Implements Mantid::Geometry::IObject.

Definition at line 387 of file MeshObject2D.cpp.

References Id.

◆ initDraw()

void Mantid::Geometry::MeshObject2D::initDraw ( ) const
overridevirtual

Implements Mantid::Geometry::IObject.

Definition at line 420 of file MeshObject2D.cpp.

References m_handler.

◆ initialize()

void Mantid::Geometry::MeshObject2D::initialize ( )
private

◆ interceptSurface()

int Mantid::Geometry::MeshObject2D::interceptSurface ( Geometry::Track ut) const
overridevirtual

◆ isOnSide()

bool Mantid::Geometry::MeshObject2D::isOnSide ( const Kernel::V3D point) const
overridevirtual

Determine if point is on the side of the object.

Parameters
point: Point to test
Returns
: True if the point is on the side

Implements Mantid::Geometry::IObject.

Definition at line 218 of file MeshObject2D.cpp.

References isValid().

◆ isValid()

bool Mantid::Geometry::MeshObject2D::isValid ( const Kernel::V3D point) const
overridevirtual

Check if a point is inside.

Check that the point is on the plane AND that it is inside or on.

MeshObject2D::isOnSide one of the triangles that defines the plane. Both must be true.

Parameters
point: Point to test
Returns
: True only if the point is valid

Implements Mantid::Geometry::IObject.

Definition at line 199 of file MeshObject2D.cpp.

References distanceToPlane(), Mantid::Geometry::MeshObjectCommon::isOnTriangle(), m_triangles, m_vertices, and tolerance.

Referenced by getPointInObject(), and isOnSide().

◆ material()

const Kernel::Material & Mantid::Geometry::MeshObject2D::material ( ) const
overridevirtual

Implements Mantid::Geometry::IObject.

Definition at line 380 of file MeshObject2D.cpp.

References m_material.

Referenced by setMaterial().

◆ numberOfTriangles()

size_t Mantid::Geometry::MeshObject2D::numberOfTriangles ( ) const

Definition at line 393 of file MeshObject2D.cpp.

References m_triangles.

◆ numberOfVertices()

size_t Mantid::Geometry::MeshObject2D::numberOfVertices ( ) const

Definition at line 391 of file MeshObject2D.cpp.

References m_vertices.

◆ operator==()

bool Mantid::Geometry::MeshObject2D::operator== ( const MeshObject2D other) const

◆ pointsCoplanar()

bool Mantid::Geometry::MeshObject2D::pointsCoplanar ( const std::vector< Kernel::V3D > &  vertices)
static

Estalish if points are coplanar.

Parameters
vertices: All vertices to consider
Returns
: Return True only if all coplanar

Definition at line 130 of file MeshObject2D.cpp.

References Mantid::Geometry::CoplanarChecks::allCoplanar(), Mantid::Kernel::V3D::norm2(), Mantid::Geometry::CoplanarChecks::sufficientPoints(), and Mantid::Geometry::CoplanarChecks::surfaceNormal().

◆ setID()

void Mantid::Geometry::MeshObject2D::setID ( const std::string &  id)
inlineoverridevirtual

Implements Mantid::Geometry::IObject.

Definition at line 73 of file MeshObject2D.h.

◆ setMaterial()

void Mantid::Geometry::MeshObject2D::setMaterial ( const Kernel::Material material)
overridevirtual
Parameters
material:: material that is being set for the object

Implements Mantid::Geometry::IObject.

Definition at line 385 of file MeshObject2D.cpp.

References m_material, and material().

◆ shape()

detail::ShapeInfo::GeometryShape Mantid::Geometry::MeshObject2D::shape ( ) const
overridevirtual

◆ shapeInfo()

const detail::ShapeInfo & Mantid::Geometry::MeshObject2D::shapeInfo ( ) const
overridevirtual

Implements Mantid::Geometry::IObject.

Definition at line 404 of file MeshObject2D.cpp.

◆ solidAngle() [1/2]

double Mantid::Geometry::MeshObject2D::solidAngle ( const Kernel::V3D observer) const
overridevirtual

Solid angle only considers triangle facing sample.

Back faces do NOT contribute.

This is tantamount to defining an object that is opaque to neutrons. Note that it is still possible to define a facing surface which is obscured by another. In that case there would still be a solid angle contribution as there is no way of detecting the shadowing.

Parameters
observer
Returns

Implements Mantid::Geometry::IObject.

Definition at line 307 of file MeshObject2D.cpp.

References Mantid::Geometry::MeshObjectCommon::getTriangleSolidAngle(), m_triangles, and m_vertices.

Referenced by solidAngle().

◆ solidAngle() [2/2]

double Mantid::Geometry::MeshObject2D::solidAngle ( const Kernel::V3D observer,
const Kernel::V3D scaleFactor 
) const
overridevirtual

Implements Mantid::Geometry::IObject.

Definition at line 319 of file MeshObject2D.cpp.

References m_material, m_triangles, m_vertices, and solidAngle().

◆ volume()

double Mantid::Geometry::MeshObject2D::volume ( ) const
overridevirtual

Implements Mantid::Geometry::IObject.

Definition at line 335 of file MeshObject2D.cpp.

Member Data Documentation

◆ Id

const std::string Mantid::Geometry::MeshObject2D::Id = "MeshObject2D"
static

Id as static.

Definition at line 76 of file MeshObject2D.h.

Referenced by id().

◆ m_boundingBox

BoundingBox Mantid::Geometry::MeshObject2D::m_boundingBox
mutableprivate

Bounding box.

Definition at line 104 of file MeshObject2D.h.

Referenced by getBoundingBox().

◆ m_handler

std::shared_ptr<GeometryHandler> Mantid::Geometry::MeshObject2D::m_handler
private

Geometry Handle for rendering.

Definition at line 106 of file MeshObject2D.h.

Referenced by draw(), getGeometryHandler(), initDraw(), and initialize().

◆ m_id

std::string Mantid::Geometry::MeshObject2D::m_id
private

optional string identifier

Definition at line 100 of file MeshObject2D.h.

◆ m_material

Kernel::Material Mantid::Geometry::MeshObject2D::m_material
private

Material composition.

Definition at line 102 of file MeshObject2D.h.

Referenced by clone(), material(), operator==(), setMaterial(), and solidAngle().

◆ m_planeParameters

struct Mantid::Geometry::MeshObject2D::PlaneParameters Mantid::Geometry::MeshObject2D::m_planeParameters
private

◆ m_triangles

std::vector<uint32_t> Mantid::Geometry::MeshObject2D::m_triangles
private

Triangles are specified by indices into a list of vertices.

Offset is always 3.

Definition at line 96 of file MeshObject2D.h.

Referenced by clone(), cloneWithMaterial(), getTriangles(), hasValidShape(), isValid(), numberOfTriangles(), operator==(), and solidAngle().

◆ m_vertices

std::vector<Kernel::V3D> Mantid::Geometry::MeshObject2D::m_vertices
private

◆ MinThickness

const double Mantid::Geometry::MeshObject2D::MinThickness = 0.001
static

Definition at line 54 of file MeshObject2D.h.


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