Go to the documentation of this file.
37 #ifndef GEOMETRIC_SHAPES_BODIES_
38 #define GEOMETRIC_SHAPES_BODIES_
40 #if __cplusplus <= 199711L
41 #error This header requires at least C++11
50 #include <Eigen/Geometry>
66 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
70 struct BoundingCylinder
72 Eigen::Isometry3d
pose;
75 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
81 typedef std::shared_ptr<Body>
BodyPtr;
97 virtual ~Body() =
default;
173 inline void setPose(
const Eigen::Isometry3d& pose)
180 inline const Eigen::Isometry3d&
getPose()
const
214 Eigen::Vector3d pt(
x,
y,
z);
219 virtual bool containsPoint(
const Eigen::Vector3d& p,
bool verbose =
false)
const = 0;
226 virtual bool intersectsRay(
const Eigen::Vector3d& origin,
const Eigen::Vector3d& dir,
239 Eigen::Vector3d& result)
const;
267 virtual BodyPtr cloneAt(
const Eigen::Isometry3d& pose,
double padding,
double scaling)
const = 0;
288 Eigen::Isometry3d
pose_;
291 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
309 explicit Sphere(
const BoundingSphere& sphere);
317 bool containsPoint(
const Eigen::Vector3d& p,
bool verbose =
false)
const override;
320 Eigen::Vector3d& result)
const override;
325 bool intersectsRay(
const Eigen::Vector3d& origin,
const Eigen::Vector3d& dir,
328 BodyPtr cloneAt(
const Eigen::Isometry3d& pose,
double padding,
double scale)
const override;
344 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
362 explicit Cylinder(
const BoundingCylinder& cylinder);
370 bool containsPoint(
const Eigen::Vector3d& p,
bool verbose =
false)
const override;
373 Eigen::Vector3d& result)
const override;
378 bool intersectsRay(
const Eigen::Vector3d& origin,
const Eigen::Vector3d& dir,
381 BodyPtr cloneAt(
const Eigen::Isometry3d& pose,
double padding,
double scale)
const override;
407 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
433 bool containsPoint(
const Eigen::Vector3d& p,
bool verbose =
false)
const override;
436 Eigen::Vector3d& result)
const override;
441 bool intersectsRay(
const Eigen::Vector3d& origin,
const Eigen::Vector3d& dir,
444 BodyPtr cloneAt(
const Eigen::Isometry3d& pose,
double padding,
double scale)
const override;
470 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
497 bool containsPoint(
const Eigen::Vector3d& p,
bool verbose =
false)
const override;
504 bool intersectsRay(
const Eigen::Vector3d& origin,
const Eigen::Vector3d& dir,
517 BodyPtr cloneAt(
const Eigen::Isometry3d& pose,
double padding,
double scale)
const override;
563 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
589 void setPose(
unsigned int i,
const Eigen::Isometry3d& pose);
595 bool containsPoint(
const Eigen::Vector3d& p,
bool verbose =
false)
const;
598 bool containsPoint(
const Eigen::Vector3d& p, std::size_t&
index,
bool verbose =
false)
const;
605 bool intersectsRay(
const Eigen::Vector3d& origin,
const Eigen::Vector3d& dir, std::size_t&
index,
616 typedef std::shared_ptr<Body>
BodyPtr;
BodyPtr cloneAt(const Eigen::Isometry3d &pose, double padding, double scale) const override
Get a clone of this body, but one that is located at the pose pose and has possibly different passing...
bool intersectsRay(const Eigen::Vector3d &origin, const Eigen::Vector3d &dir, EigenSTL::vector_Vector3d *intersections=nullptr, unsigned int count=0) const override
Check if a ray intersects the body, and find the set of intersections, in order, along the ray....
void computeBoundingSphere(BoundingSphere &sphere) const override
Compute the bounding radius for the body, in its current pose. Scaling and padding are accounted for.
std::vector< double > getDimensions() const override
Returns an empty vector.
bool intersectsRay(const Eigen::Vector3d &origin, const Eigen::Vector3d &dir, EigenSTL::vector_Vector3d *intersections=nullptr, unsigned int count=0) const override
Check if a ray intersects the body, and find the set of intersections, in order, along the ray....
bool isPointInsidePlanes(const Eigen::Vector3d &point) const
Check if the point is inside all halfspaces this mesh consists of (mesh_data_->planes_).
double computeVolume() const override
Compute the volume of the body. This method includes changes induced by scaling and padding.
std::shared_ptr< MeshData > mesh_data_
Definition of various shapes. No properties such as position are included. These are simply the descr...
std::vector< Eigen::Isometry3d, Eigen::aligned_allocator< Eigen::Isometry3d > > vector_Isometry3d
std::unique_ptr< EigenSTL::vector_Vector3d > scaled_vertices_storage_
double computeVolume() const override
Compute the volume of the body. This method includes changes induced by scaling and padding.
double scale_
The scale that was set for this body.
Eigen::Vector3d normalB1_
bool containsPoint(const Eigen::Vector3d &p, bool verbose=false) const override
Check if a point is inside the body. Surface points are included.
void useDimensions(const shapes::Shape *shape) override
Depending on the shape, this function copies the relevant data to the body.
void setPoseDirty(const Eigen::Isometry3d &pose)
Set the pose of the body.
BodyPtr cloneAt(const Eigen::Isometry3d &pose, double padding, double scale) const override
Get a clone of this body, but one that is located at the pose pose and has possibly different passing...
Eigen::Isometry3d pose_
The location of the body (position and orientation)
virtual bool intersectsRay(const Eigen::Vector3d &origin, const Eigen::Vector3d &dir, EigenSTL::vector_Vector3d *intersections=nullptr, unsigned int count=0) const =0
Check if a ray intersects the body, and find the set of intersections, in order, along the ray....
std::vector< Eigen::Vector4d, Eigen::aligned_allocator< Eigen::Vector4d > > vector_Vector4d
void useDimensions(const shapes::Shape *shape) override
Depending on the shape, this function copies the relevant data to the body.
virtual double computeVolume() const =0
Compute the volume of the body. This method includes changes induced by scaling and padding.
void updateInternalData() override
This function is called every time a change to the body is made, so that intermediate values stored f...
void setDimensionsDirty(const shapes::Shape *shape)
Set the dimensions of the body (from corresponding shape).
std::vector< double > getScaledDimensions() const override
Get the dimensions associated to this body (scaled and padded)
std::vector< double > getDimensions() const override
Get the radius & length of the cylinder.
void computeBoundingSphere(BoundingSphere &sphere) const override
Compute the bounding radius for the body, in its current pose. Scaling and padding are accounted for.
bool intersectsRay(const Eigen::Vector3d &origin, const Eigen::Vector3d &dir, EigenSTL::vector_Vector3d *intersections=nullptr, unsigned int count=0) const override
Check if a ray intersects the body, and find the set of intersections, in order, along the ray....
unsigned int countVerticesBehindPlane(const Eigen::Vector4f &planeNormal) const
(Used mainly for debugging) Count the number of vertices behind a plane
bool containsPoint(const Eigen::Vector3d &p, bool verbose=false) const override
Check if a point is inside the body. Surface points are included.
double computeVolume() const override
Compute the volume of the body. This method includes changes induced by scaling and padding.
void computeBoundingBox(AABB &bbox) const override
Compute the axis-aligned bounding box for the body, in its current pose. Scaling and padding are acco...
virtual void computeBoundingCylinder(BoundingCylinder &cylinder) const =0
Compute the bounding cylinder for the body, in its current pose. Scaling and padding are accounted fo...
bool containsPoint(double x, double y, double z, bool verbose=false) const
Check if a point is inside the body.
~Cylinder() override=default
void setPose(unsigned int i, const Eigen::Isometry3d &pose)
Set the pose of a particular body in the vector of bodies.
A basic definition of a shape. Shapes are considered centered at origin.
BodyPtr cloneAt(const Eigen::Isometry3d &pose, double padding, double scale) const override
Get a clone of this body, but one that is located at the pose pose and has possibly different passing...
bool containsPoint(const Eigen::Vector3d &p, bool verbose=false) const override
Check if a point is inside the body. Surface points are included.
std::vector< double > getDimensions() const override
Get the radius of the sphere.
A body is a shape + its pose. Point inclusion, ray intersection can be tested, volumes and bounding s...
void computeBoundingCylinder(BoundingCylinder &cylinder) const override
Compute the bounding cylinder for the body, in its current pose. Scaling and padding are accounted fo...
virtual void computeBoundingSphere(BoundingSphere &sphere) const =0
Compute the bounding radius for the body, in its current pose. Scaling and padding are accounted for.
virtual std::vector< double > getScaledDimensions() const =0
Get the dimensions associated to this body (scaled and padded)
std::vector< double > getDimensions() const override
Get the length & width & height (x, y, z) of the box.
double computeVolume() const override
Compute the volume of the body. This method includes changes induced by scaling and padding.
const Body * getBody(unsigned int i) const
Get the ith body in the vector.
bool containsPoint(const Eigen::Vector3d &p, bool verbose=false) const
Check if any body in the vector contains the input point.
virtual void useDimensions(const shapes::Shape *shape)=0
Depending on the shape, this function copies the relevant data to the body.
double getPadding() const
Retrieve the current padding.
Definition of a sphere that bounds another object.
void computeBoundingBox(AABB &bbox) const override
Compute the axis-aligned bounding box for the body, in its current pose. Scaling and padding are acco...
virtual bool samplePointInside(random_numbers::RandomNumberGenerator &rng, unsigned int max_attempts, Eigen::Vector3d &result) const
Sample a point that is included in the body using a given random number generator.
void setScaleDirty(double scale)
If the dimension of the body should be scaled, this method sets the scale.
std::vector< double > getScaledDimensions() const override
Returns an empty vector.
void updateInternalData() override
This function is called every time a change to the body is made, so that intermediate values stored f...
void computeBoundingBox(AABB &bbox) const override
Compute the axis-aligned bounding box for the body, in its current pose. Scaling and padding are acco...
void computeBoundingCylinder(BoundingCylinder &cylinder) const override
Compute the bounding cylinder for the body, in its current pose. Scaling and padding are accounted fo...
std::vector< Body * > bodies_
Represents an oriented bounding box.
void updateInternalData() override
This function is called every time a change to the body is made, so that intermediate values stored f...
Eigen::Vector3d maxCorner_
The translated, but not rotated max corner.
shapes::ShapeType type_
The type of shape this body was constructed from.
Definition of a cylinder.
std::vector< Eigen::Vector3d, Eigen::aligned_allocator< Eigen::Vector3d > > vector_Vector3d
ShapeType
A list of known shape types.
virtual std::vector< double > getDimensions() const =0
Get the dimensions associated to this body (as read from corresponding shape)
void computeBoundingBox(AABB &bbox) const override
Compute the axis-aligned bounding box for the body, in its current pose. Scaling and padding are acco...
bool intersectsRay(const Eigen::Vector3d &origin, const Eigen::Vector3d &dir, std::size_t &index, EigenSTL::vector_Vector3d *intersections=nullptr, unsigned int count=0) const
Check if any of the bodies intersects the ray defined by origin and dir. When the first intersection ...
shapes::ShapeType getType() const
Get the type of shape this body represents.
std::vector< double > getScaledDimensions() const override
Get the dimensions associated to this body (scaled and padded)
const std::vector< unsigned int > & getTriangles() const
void useDimensions(const shapes::Shape *shape) override
Depending on the shape, this function copies the relevant data to the body.
const Eigen::Isometry3d & getPose() const
Retrieve the pose of the body.
virtual void updateInternalData()=0
This function is called every time a change to the body is made, so that intermediate values stored f...
void useDimensions(const shapes::Shape *shape) override
Depending on the shape, this function copies the relevant data to the body.
Eigen::Vector3d minCorner_
The translated, but not rotated min corner.
std::size_t getCount() const
Get the number of bodies in this vector.
Eigen::Vector3d normalB2_
void setDimensions(const shapes::Shape *shape)
Set the dimensions of the body (from corresponding shape)
void addBody(Body *body)
Add a body.
bool samplePointInside(random_numbers::RandomNumberGenerator &rng, unsigned int max_attempts, Eigen::Vector3d &result) const override
Sample a point that is included in the body using a given random number generator.
Eigen::Isometry3d i_pose_
void correctVertexOrderFromPlanes()
std::chrono::system_clock::time_point point
std::shared_ptr< Body > BodyPtr
Shared pointer to a Body.
std::vector< double > getScaledDimensions() const override
Get the dimensions associated to this body (scaled and padded)
~ConvexMesh() override=default
void computeBoundingCylinder(BoundingCylinder &cylinder) const override
Compute the bounding cylinder for the body, in its current pose. Scaling and padding are accounted fo...
double getScale() const
Retrieve the current scale.
~Sphere() override=default
std::shared_ptr< const Body > BodyConstPtr
Shared pointer to a const Body.
void setPaddingDirty(double padd)
If the dimension of the body should be padded, this method sets the pading.
This set of classes allows quickly detecting whether a given point is inside an object or not....
void setScale(double scale)
If the dimension of the body should be scaled, this method sets the scale. Default is 1....
virtual void computeBoundingBox(AABB &bbox) const =0
Compute the axis-aligned bounding box for the body, in its current pose. Scaling and padding are acco...
void setPose(const Eigen::Isometry3d &pose)
Set the pose of the body. Default is identity.
double padding_
The scale that was set for this body.
const EigenSTL::vector_Vector3d & getScaledVertices() const
void computeBoundingSphere(BoundingSphere &sphere) const override
Compute the bounding radius for the body, in its current pose. Scaling and padding are accounted for.
void setPadding(double padd)
If constant padding should be added to the body, this method sets the padding. Default is 0....
bool samplePointInside(random_numbers::RandomNumberGenerator &rng, unsigned int max_attempts, Eigen::Vector3d &result) const override
Sample a point that is included in the body using a given random number generator.
EigenSTL::vector_Vector3d * scaled_vertices_
bool intersectsRay(const Eigen::Vector3d &origin, const Eigen::Vector3d &dir, EigenSTL::vector_Vector3d *intersections=nullptr, unsigned int count=0) const override
Check if a ray intersects the body, and find the set of intersections, in order, along the ray....
BodyPtr cloneAt(const Eigen::Isometry3d &pose, double padding, double scale) const override
Get a clone of this body, but one that is located at the pose pose and has possibly different passing...
void computeScaledVerticesFromPlaneProjections()
Project the original vertex to the scaled and padded planes and average.
A vector of Body objects.
Definition of a cylinder.
void updateInternalData() override
This function is called every time a change to the body is made, so that intermediate values stored f...
Definition of a convex mesh. Convex hull is computed for a given shape::Mesh.
void clear()
Clear all bodies from the vector.
bool containsPoint(const Eigen::Vector3d &p, bool verbose=false) const override
Check if a point is inside the body. Surface points are included.
void computeBoundingCylinder(BoundingCylinder &cylinder) const override
Compute the bounding cylinder for the body, in its current pose. Scaling and padding are accounted fo...
const EigenSTL::vector_Vector4d & getPlanes() const
Get the planes that define the convex shape.
bool samplePointInside(random_numbers::RandomNumberGenerator &rng, unsigned int max_attempts, Eigen::Vector3d &result) const override
Sample a point that is included in the body using a given random number generator.
const EigenSTL::vector_Vector3d & getVertices() const
Represents an axis-aligned bounding box.
BodyPtr cloneAt(const Eigen::Isometry3d &pose) const
Get a clone of this body, but one that is located at the pose pose.
void computeBoundingSphere(BoundingSphere &sphere) const override
Compute the bounding radius for the body, in its current pose. Scaling and padding are accounted for.
geometric_shapes
Author(s): Ioan Sucan
, Gil Jones
autogenerated on Tue Aug 13 2024 02:40:57