geolib2
|
A geometric description of a shape. More...
#include <Shape.h>
Public Member Functions | |
virtual Shape * | clone () const |
virtual bool | contains (const Vector3 &p) const |
Determines whether a point p lies within the shape. More... | |
virtual bool | empty () const |
empty Test whether the shape(mesh) is empty. More... | |
virtual Box | getBoundingBox () const |
Returns the smallest box which includes all mesh points. Box is not rotated, but matches the axis of the Shape. More... | |
virtual double | getMaxRadius () const |
Calculate the maximum distance from the origin of the shape to any point of the shape. More... | |
virtual const Mesh & | getMesh () const |
return the mesh defining the shape More... | |
virtual bool | intersect (const Ray &r, float t0, float t1, double &distance) const |
intersect: currently always throws a logic error More... | |
virtual bool | intersect (const Vector3 &p, const double radius) const |
Determines whether the shape intersects a sphere with center p. More... | |
virtual void | setMesh (const Mesh &mesh) |
set the Mesh Any child classes should throw a std::logic_error in case the mesh should not be changed via setMesh. More... | |
Shape () | |
virtual bool | write (std::ostream &output) const |
write, serialise the shape More... | |
virtual | ~Shape () |
Static Public Member Functions | |
static ShapePtr | read (std::istream &input) |
read serialised data from an input stream and create a shape More... | |
Static Public Attributes | |
static const std::string | TYPE = "mesh" |
Protected Attributes | |
Mesh | mesh_ |
Should not be read or written to directly in general. Use setMesh and getMesh to write respectively read the mesh. In a few exceptions, the mesh can be written direcly. Make sure that mesh keeps consistent with other member variables. More... | |
Private Attributes | |
bool | bounding_box_cache_valid_ |
Vector3 | bounding_box_max_cache_ |
Vector3 | bounding_box_min_cache_ |
Friends | |
class | Importer |
A geometric description of a shape.
Defines a shape using a triangle mesh. The origin of the shape is not necesarily in the centre of the shape.
|
virtual |
Reimplemented in geo::HeightMap, geo::CompositeShape, geo::Octree, and geo::Box.
|
virtual |
Determines whether a point p lies within the shape.
p | point to test |
Let the line segment P connect points p and an arbitrary point p_out outside of the shape We count the number of intersections between P and the shape. A positive number means point p is inside the shape. We use plucker coordinates to determine whether or not a triangle intersects line segment P. more details https://members.loria.fr/SLazard/ARC-Visi3D/Pant-project/files/Line_Segment_Triangle.html
Reimplemented in geo::Octree, geo::Box, and geo::CompositeShape.
|
inlinevirtual |
|
virtual |
|
virtual |
Calculate the maximum distance from the origin of the shape to any point of the shape.
Reimplemented in geo::Box, geo::Octree, and geo::CompositeShape.
|
virtual |
return the mesh defining the shape
Reimplemented in geo::Octree.
|
virtual |
intersect: currently always throws a logic error
r | |
t0 | |
t1 | |
distance |
Reimplemented in geo::Octree, geo::CompositeShape, geo::Box, and geo::HeightMap.
|
virtual |
Determines whether the shape intersects a sphere with center p.
p | center of the sphere |
radius | radius of the sphere |
Main logic: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.49.9172&rep=rep1&type=pdf Projection in triangle logic: https://www.baeldung.com/cs/check-if-point-is-in-2d-triangle#1-mathematical-idea-2
Reimplemented in geo::Box, and geo::CompositeShape.
|
static |
|
virtual |
set the Mesh Any child classes should throw a std::logic_error in case the mesh should not be changed via setMesh.
mesh | mesh to set |
Reimplemented in geo::Box, and geo::CompositeShape.
|
virtual |
|
protected |
|
static |