Mantid
|
Triangular Mesh Object. More...
#include <MeshObject.h>
Public Member Functions | |
int | calcValidType (const Kernel::V3D &Pt, const Kernel::V3D &uVec) const |
Calculate if a point PT is a valid point on the track. More... | |
IObject * | clone () const override |
Clone. More... | |
IObject * | cloneWithMaterial (const Kernel::Material &material) const override |
double | distance (const Track &track) const override |
Compute the distance to the first point of intersection with the surface. More... | |
void | draw () const override |
Draws the Object using geometry handler, If the handler is not set then this function does nothing. More... | |
boost::optional< Kernel::V3D > | generatePointInObject (Kernel::PseudoRandomNumberGenerator &rng, const BoundingBox &activeRegion, const size_t) const override |
Generate a random point within the object that is also bound by the activeRegion box. More... | |
boost::optional< Kernel::V3D > | generatePointInObject (Kernel::PseudoRandomNumberGenerator &rng, const size_t) const override |
Select a random point within the object. More... | |
const BoundingBox & | getBoundingBox () const override |
Return cached value of axis-aligned bounding box. 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< GeometryHandler > | getGeometryHandler () const override |
Returns the geometry handler. More... | |
int | getName () const override |
void | GetObjectGeom (detail::ShapeInfo::GeometryShape &type, std::vector< Kernel::V3D > &vectors, double &innerRadius, double &radius, double &height) const override |
get info on standard shapes (none for Mesh Object) More... | |
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 |
get faces More... | |
const std::vector< Kernel::V3D > & | getV3Ds () const |
get vertices in V3D form More... | |
std::vector< double > | getVertices () const |
get vertices More... | |
bool | hasValidShape () const override |
Return whether this object has a valid shape. More... | |
const std::string & | id () const override |
void | initDraw () const override |
Initializes/prepares the object to be rendered, this will generate geometry for object, If the handler is not set then this function does nothing. More... | |
int | interceptSurface (Geometry::Track &) const override |
Given a track, fill the track with valid section. More... | |
bool | isOnSide (const Kernel::V3D &) const override |
Determines wither point is on the surface. More... | |
bool | isValid (const Kernel::V3D &) const override |
Check if a point is inside. More... | |
const Kernel::Material & | material () const override |
MeshObject (const MeshObject &)=delete | |
Copy constructor. More... | |
MeshObject (std::vector< uint32_t > &&faces, std::vector< Kernel::V3D > &&vertices, const Kernel::Material &&material) | |
Constructor. More... | |
MeshObject (std::vector< uint32_t > faces, std::vector< Kernel::V3D > vertices, const Kernel::Material &material) | |
Constructor. More... | |
void | multiply (const Kernel::Matrix< double > &) |
Transform the mesh (scale, translate, rotate) according to the supplied transformation matrix. More... | |
size_t | numberOfTriangles () const |
Output functions for rendering, may also be used internally. More... | |
size_t | numberOfVertices () const |
Read access to mesh object for rendering. More... | |
MeshObject & | operator= (const MeshObject &)=delete |
Assignment operator. More... | |
void | rotate (const Kernel::Matrix< double > &) |
Rotate the mesh according to the supplied rotation matrix. More... | |
void | scale (const double scaleFactor) |
Scale the mesh according to the supplied scale factor. More... | |
void | setGeometryHandler (const std::shared_ptr< GeometryHandler > &h) |
Set Geometry Handler. More... | |
void | setID (const std::string &id) override |
void | setMaterial (const Kernel::Material &material) override |
detail::ShapeInfo::GeometryShape | shape () const override |
const detail::ShapeInfo & | shapeInfo () const override |
double | solidAngle (const Kernel::V3D &observer) const override |
Find solid angle of object wrt the observer. More... | |
double | solidAngle (const Kernel::V3D &observer, const Kernel::V3D &scaleFactor) const override |
Find solid angle of object wrt the observer with a scaleFactor for the object. More... | |
void | translate (const Kernel::V3D &) |
Translate the mesh according to the supplied x, y, z vector. More... | |
void | updateGeometryHandler () |
Updates the geometry handler if needed. More... | |
double | volume () const override |
Calculates the volume of this object. More... | |
virtual | ~MeshObject ()=default |
Destructor. More... | |
Public Member Functions inherited from Mantid::Geometry::IObject | |
virtual IObject * | clone () const =0 |
virtual IObject * | cloneWithMaterial (const Kernel::Material &material) const =0 |
virtual double | distance (const Geometry::Track &) const =0 |
virtual void | draw () const =0 |
virtual boost::optional< Kernel::V3D > | generatePointInObject (Kernel::PseudoRandomNumberGenerator &rng, const BoundingBox &activeRegion, const size_t) const =0 |
virtual boost::optional< Kernel::V3D > | generatePointInObject (Kernel::PseudoRandomNumberGenerator &rng, const size_t) const =0 |
virtual const BoundingBox & | getBoundingBox () 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< GeometryHandler > | getGeometryHandler () 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::Material & | material () 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::ShapeInfo & | shapeInfo () 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 |
Private Member Functions | |
void | getIntersections (const Kernel::V3D &start, const Kernel::V3D &direction, std::vector< Kernel::V3D > &intersectionPoints, std::vector< Mantid::Geometry::TrackDirection > &entryExitFlags) const |
Get intersections. More... | |
bool | getTriangle (const size_t index, Kernel::V3D &v1, Kernel::V3D &v2, Kernel::V3D &v3) const |
Get triangle. More... | |
void | initialize () |
bool | searchForObject (Kernel::V3D &point) const |
Search object for valid point. More... | |
Private Attributes | |
BoundingBox | m_boundingBox |
Cache for object's bounding box. More... | |
std::shared_ptr< GeometryHandler > | m_handler |
Geometry Handle for rendering. More... | |
std::string | m_id |
string to return as ID More... | |
Kernel::Material | m_material |
material composition More... | |
std::string | m_string |
const double | M_TOLERANCE = 0.000001 |
Tolerence distance. More... | |
std::vector< uint32_t > | m_triangles |
Contents Triangles are specified by indices into a list of vertices. More... | |
std::vector< Kernel::V3D > | m_vertices |
std::shared_ptr< vtkGeometryCacheReader > | m_vtk_cache_reader |
a pointer to a class for reading from the geometry cache More... | |
std::shared_ptr< vtkGeometryCacheWriter > | m_vtk_cache_writer |
a pointer to a class for writing to the geometry cache More... | |
Triangular Mesh Object.
Mesh Object of Triangles assumed to form one or more non-intersecting closed surfaces enclosing separate volumes. The number of vertices is limited to 2^32 based on index type. For 2D Meshes see Mesh2DObject
Definition at line 50 of file MeshObject.h.
Mantid::Geometry::MeshObject::MeshObject | ( | std::vector< uint32_t > | faces, |
std::vector< Kernel::V3D > | vertices, | ||
const Kernel::Material & | material | ||
) |
Mantid::Geometry::MeshObject::MeshObject | ( | std::vector< uint32_t > && | faces, |
std::vector< Kernel::V3D > && | vertices, | ||
const Kernel::Material && | material | ||
) |
|
delete |
Copy constructor.
|
virtualdefault |
Destructor.
int Mantid::Geometry::MeshObject::calcValidType | ( | const Kernel::V3D & | point, |
const Kernel::V3D & | uVec | ||
) | const |
Calculate if a point PT is a valid point on the track.
point | :: Point to calculate from. |
uVec | :: Unit vector of the track |
0 | :: Not valid / double valid |
1 | :: Entry point |
-1 | :: Exit Point |
Definition at line 240 of file MeshObject.cpp.
References isValid(), and Mantid::Kernel::Tolerance.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Implements Mantid::Geometry::IObject.
Definition at line 65 of file MeshObject.h.
|
overridevirtual |
Compute the distance to the first point of intersection with the surface.
track | Track defining start/direction |
std::runtime_error | if no intersection was found |
Implements Mantid::Geometry::IObject.
Definition at line 176 of file MeshObject.cpp.
References Mantid::Geometry::Track::direction(), Mantid::Kernel::V3D::distance(), getTriangle(), Mantid::Geometry::intersection(), Mantid::Geometry::MeshObjectCommon::rayIntersectsTriangle(), and Mantid::Geometry::Track::startPoint().
|
overridevirtual |
Draws the Object using geometry handler, If the handler is not set then this function does nothing.
Implements Mantid::Geometry::IObject.
Definition at line 444 of file MeshObject.cpp.
References m_handler.
|
overridevirtual |
Generate a random point within the object that is also bound by the activeRegion box.
rng | A reference to a PseudoRandomNumberGenerator where nextValue should return a flat random number between 0.0 & 1.0 |
activeRegion | Restrict point generation to this sub-region of the object |
maxAttempts | The maximum number of attempts at generating a point |
Implements Mantid::Geometry::IObject.
Definition at line 397 of file MeshObject.cpp.
References Mantid::Geometry::RandomPoint::bounded().
|
overridevirtual |
Select a random point within the object.
Generate a random point within the object.
The method simply generates a point within the bounding box and tests if this is a valid point within the object: if so the point is return otherwise a new point is selected.
rng | A reference to a PseudoRandomNumberGenerator where nextValue should return a flat random number between 0.0 & 1.0 |
maxAttempts | The maximum number of attempts at generating a point |
Implements Mantid::Geometry::IObject.
Definition at line 377 of file MeshObject.cpp.
References generatePointInObject(), and getBoundingBox().
Referenced by generatePointInObject().
|
overridevirtual |
Return cached value of axis-aligned bounding box.
Returns an axis-aligned bounding box that will fit the shape.
Implements Mantid::Geometry::IObject.
Definition at line 343 of file MeshObject.cpp.
References Mantid::Geometry::MeshObjectCommon::getBoundingBox(), m_boundingBox, and m_vertices.
Referenced by generatePointInObject(), getPointInObject(), interceptSurface(), isOnSide(), isValid(), and volume().
|
overridevirtual |
Calculate (or return cached value of) Axis Aligned Bounding box (DEPRECATED)
Takes input axis aligned bounding box max and min points and calculates the bounding box for the object and returns them back in max and min points.
xmax | :: Maximum value for the bounding box in x direction |
ymax | :: Maximum value for the bounding box in y direction |
zmax | :: Maximum value for the bounding box in z direction |
xmin | :: Minimum value for the bounding box in x direction |
ymin | :: Minimum value for the bounding box in y direction |
zmin | :: Minimum value for the bounding box in z direction |
Implements Mantid::Geometry::IObject.
Definition at line 263 of file MeshObject.cpp.
References Mantid::Geometry::MeshObjectCommon::getBoundingBox(), m_boundingBox, and m_vertices.
|
overridevirtual |
Returns the geometry handler.
Implements Mantid::Geometry::IObject.
Definition at line 466 of file MeshObject.cpp.
References m_handler.
|
private |
Get intersections.
Get intersection points and their in out directions on the given ray.
start | :: Start point of ray |
direction | :: Direction of ray |
intersectionPoints | :: Intersection points (not sorted) |
entryExitFlags | :: +1 ray enters -1 ray exits at corresponding point |
Definition at line 198 of file MeshObject.cpp.
References getTriangle(), Mantid::Geometry::intersection(), and Mantid::Geometry::MeshObjectCommon::rayIntersectsTriangle().
Referenced by interceptSurface(), isOnSide(), and isValid().
|
inlineoverridevirtual |
Implements Mantid::Geometry::IObject.
Definition at line 72 of file MeshObject.h.
|
overridevirtual |
get info on standard shapes (none for Mesh Object)
Implements Mantid::Geometry::IObject.
Definition at line 565 of file MeshObject.cpp.
References height, innerRadius, m_handler, Mantid::Geometry::detail::ShapeInfo::NOSHAPE, and radius.
|
overridevirtual |
Try to find a point that lies within (or on) the object.
[out] | point | :: on exit set to the point value, if found |
Implements Mantid::Geometry::IObject.
Definition at line 352 of file MeshObject.cpp.
References Mantid::Geometry::BoundingBox::centrePoint(), getBoundingBox(), Mantid::Geometry::BoundingBox::isNonNull(), and searchForObject().
|
private |
Get triangle.
Definition at line 221 of file MeshObject.cpp.
References index, m_triangles, and m_vertices.
Referenced by distance(), getIntersections(), solidAngle(), and volume().
std::vector< uint32_t > Mantid::Geometry::MeshObject::getTriangles | ( | ) | const |
get faces
Definition at line 539 of file MeshObject.cpp.
References m_triangles.
Referenced by Mantid::DataHandling::SaveSampleEnvironmentAndShape::addMeshToVector(), and Mantid::DataHandling::Mantid3MFFileIO::writeMeshObject().
const std::vector< Kernel::V3D > & Mantid::Geometry::MeshObject::getV3Ds | ( | ) | const |
get vertices in V3D form
Definition at line 554 of file MeshObject.cpp.
References m_vertices.
Referenced by Mantid::DataHandling::SaveSampleEnvironmentAndShape::addMeshToVector(), and Mantid::DataHandling::Mantid3MFFileIO::writeMeshObject().
std::vector< double > Mantid::Geometry::MeshObject::getVertices | ( | ) | const |
get vertices
Definition at line 549 of file MeshObject.cpp.
References Mantid::Geometry::MeshObjectCommon::getVertices(), and m_vertices.
|
overridevirtual |
Return whether this object has a valid shape.
Returns whether this object has a valid shape.
Implements Mantid::Geometry::IObject.
Definition at line 60 of file MeshObject.cpp.
References numberOfTriangles(), and numberOfVertices().
Referenced by Mantid::DataHandling::SaveSampleEnvironmentAndShape::exec().
|
inlineoverridevirtual |
Implements Mantid::Geometry::IObject.
Definition at line 70 of file MeshObject.h.
Referenced by Mantid::DataHandling::Mantid3MFFileIO::writeMeshObject().
|
overridevirtual |
Initializes/prepares the object to be rendered, this will generate geometry for object, If the handler is not set then this function does nothing.
Implements Mantid::Geometry::IObject.
Definition at line 456 of file MeshObject.cpp.
References m_handler.
|
private |
Definition at line 39 of file MeshObject.cpp.
References Mantid::Geometry::MeshObjectCommon::checkVertexLimit(), m_handler, and m_vertices.
Referenced by MeshObject().
|
overridevirtual |
Given a track, fill the track with valid section.
UT | :: Initial track |
Implements Mantid::Geometry::IObject.
Definition at line 147 of file MeshObject.cpp.
References Mantid::Geometry::Track::addPoint(), Mantid::Geometry::Track::buildLink(), Mantid::Geometry::Track::count(), Mantid::Geometry::Track::direction(), Mantid::Geometry::BoundingBox::doesLineIntersect(), getBoundingBox(), getIntersections(), and Mantid::Geometry::Track::startPoint().
Referenced by searchForObject(), and Mantid::DataHandling::Mantid3MFFileIO::writeMeshObject().
|
overridevirtual |
Determines wither point is on the surface.
point | :: Point to check |
Implements Mantid::Geometry::IObject.
Definition at line 112 of file MeshObject.cpp.
References getBoundingBox(), getIntersections(), and Mantid::Geometry::BoundingBox::isPointInside().
|
overridevirtual |
Check if a point is inside.
Determines whether point is within the object or on the surface.
point | :: Point to be tested |
Implements Mantid::Geometry::IObject.
Definition at line 71 of file MeshObject.cpp.
References Mantid::Kernel::V3D::distance(), getBoundingBox(), getIntersections(), Mantid::Geometry::BoundingBox::isPointInside(), and Mantid::Geometry::LEAVING.
Referenced by calcValidType(), and searchForObject().
|
overridevirtual |
Implements Mantid::Geometry::IObject.
Definition at line 48 of file MeshObject.cpp.
References m_material.
Referenced by setMaterial(), and Mantid::DataHandling::Mantid3MFFileIO::writeMeshObject().
void Mantid::Geometry::MeshObject::multiply | ( | const Kernel::Matrix< double > & | matrix | ) |
Transform the mesh (scale, translate, rotate) according to the supplied transformation matrix.
matrix | 4 x 4 transformation matrix |
Definition at line 504 of file MeshObject.cpp.
References m_vertices, Mantid::Kernel::Matrix< T >::multiplyPoint(), Mantid::Kernel::Matrix< T >::numCols(), and Mantid::Kernel::Matrix< T >::numRows().
size_t Mantid::Geometry::MeshObject::numberOfTriangles | ( | ) | const |
Output functions for rendering, may also be used internally.
Definition at line 534 of file MeshObject.cpp.
References m_triangles.
Referenced by Mantid::DataHandling::SaveSampleEnvironmentAndShape::exec(), hasValidShape(), and Mantid::DataHandling::Mantid3MFFileIO::writeMeshObject().
size_t Mantid::Geometry::MeshObject::numberOfVertices | ( | ) | const |
Read access to mesh object for rendering.
get number of points
Definition at line 544 of file MeshObject.cpp.
References m_vertices.
Referenced by Mantid::DataHandling::SaveSampleEnvironmentAndShape::exec(), hasValidShape(), and Mantid::DataHandling::SaveSampleEnvironmentAndShape::mergeSampleEnvironmentIntoSingleMesh().
|
delete |
Assignment operator.
void Mantid::Geometry::MeshObject::rotate | ( | const Kernel::Matrix< double > & | rotationMatrix | ) |
Rotate the mesh according to the supplied rotation matrix.
rotationMatrix | Rotation matrix to be applied |
Definition at line 476 of file MeshObject.cpp.
References m_vertices.
void Mantid::Geometry::MeshObject::scale | ( | const double | scaleFactor | ) |
Scale the mesh according to the supplied scale factor.
scaleFactor | Scale factor |
Definition at line 494 of file MeshObject.cpp.
References m_vertices.
|
private |
Search object for valid point.
Try to find a point that lies within (or on) the object, given a seed point.
point | :: on entry the seed point, on exit point in object, if found |
Definition at line 411 of file MeshObject.cpp.
References Mantid::Geometry::Track::cbegin(), interceptSurface(), and isValid().
Referenced by getPointInObject().
void Mantid::Geometry::MeshObject::setGeometryHandler | ( | const std::shared_ptr< GeometryHandler > & | h | ) |
Set Geometry Handler.
Set the geometry handler for Object.
[in] | h | is pointer to the geometry handler. don't delete this pointer in the calling function. |
Definition at line 434 of file MeshObject.cpp.
References m_handler.
|
inlineoverridevirtual |
Implements Mantid::Geometry::IObject.
Definition at line 69 of file MeshObject.h.
|
overridevirtual |
material | :: material that is being set for the object |
Implements Mantid::Geometry::IObject.
Definition at line 53 of file MeshObject.cpp.
References m_material, and material().
|
overridevirtual |
Implements Mantid::Geometry::IObject.
Definition at line 556 of file MeshObject.cpp.
References Mantid::Geometry::detail::ShapeInfo::NOSHAPE.
|
overridevirtual |
Implements Mantid::Geometry::IObject.
Definition at line 558 of file MeshObject.cpp.
|
overridevirtual |
Find solid angle of object wrt the observer.
observer | :: point to measure solid angle from |
Implements Mantid::Geometry::IObject.
Definition at line 273 of file MeshObject.cpp.
References getTriangle(), and Mantid::Geometry::MeshObjectCommon::getTriangleSolidAngle().
Referenced by solidAngle().
|
overridevirtual |
Find solid angle of object wrt the observer with a scaleFactor for the object.
observer | :: point to measure solid angle from |
scaleFactor | :: Kernel::V3D giving scaling of the object |
Implements Mantid::Geometry::IObject.
Definition at line 301 of file MeshObject.cpp.
References m_material, m_triangles, m_vertices, and solidAngle().
void Mantid::Geometry::MeshObject::translate | ( | const Kernel::V3D & | translationVector | ) |
Translate the mesh according to the supplied x, y, z vector.
translationVector | Translation vector to be applied |
Definition at line 485 of file MeshObject.cpp.
References m_vertices.
void Mantid::Geometry::MeshObject::updateGeometryHandler | ( | ) |
Updates the geometry handler if needed.
Definition at line 527 of file MeshObject.cpp.
|
overridevirtual |
Calculates the volume of this object.
Calculate volume.
Implements Mantid::Geometry::IObject.
Definition at line 314 of file MeshObject.cpp.
References Mantid::Kernel::V3D::cross_prod(), getBoundingBox(), getTriangle(), Mantid::Kernel::V3D::scalar_prod(), Mantid::Geometry::BoundingBox::xMax(), Mantid::Geometry::BoundingBox::xMin(), Mantid::Geometry::BoundingBox::yMax(), Mantid::Geometry::BoundingBox::yMin(), Mantid::Geometry::BoundingBox::zMax(), and Mantid::Geometry::BoundingBox::zMin().
|
mutableprivate |
Cache for object's bounding box.
Definition at line 154 of file MeshObject.h.
Referenced by getBoundingBox().
|
private |
Geometry Handle for rendering.
Definition at line 160 of file MeshObject.h.
Referenced by draw(), getGeometryHandler(), GetObjectGeom(), initDraw(), initialize(), and setGeometryHandler().
|
private |
string to return as ID
Definition at line 166 of file MeshObject.h.
|
private |
material composition
Definition at line 178 of file MeshObject.h.
Referenced by material(), setMaterial(), and solidAngle().
|
private |
Definition at line 163 of file MeshObject.h.
|
private |
Tolerence distance.
Definition at line 157 of file MeshObject.h.
|
private |
Contents Triangles are specified by indices into a list of vertices.
Definition at line 175 of file MeshObject.h.
Referenced by getTriangle(), getTriangles(), numberOfTriangles(), and solidAngle().
|
private |
Definition at line 176 of file MeshObject.h.
Referenced by getBoundingBox(), getTriangle(), getV3Ds(), getVertices(), initialize(), multiply(), numberOfVertices(), rotate(), scale(), solidAngle(), and translate().
|
private |
a pointer to a class for reading from the geometry cache
Definition at line 169 of file MeshObject.h.
|
private |
a pointer to a class for writing to the geometry cache
Definition at line 171 of file MeshObject.h.