Commit 6371e2c6 authored by Nicolas CHEVAUGEON's avatar Nicolas CHEVAUGEON

[xtensor] added file xboundingBox.h

 in file xTensor/src/xBoundingBox.h
 added class xBoundingBox in xTensor.
 it helps to manipulate bounding box thanks to the member functions,
 and will permit to remove some code duplication regarding bounding box
 intersection or checking if a point is inside a bounding box,
 compared to a model were we just pass around two xPoint.
parent e6740a5b
#ifndef XBOUNDINGBOX_H
#define XBOUNDINGBOX_H
#include "xPoint.h"
namespace xtensor
{
/// xBounding box define a cartesian bounding box by its 2 corners : min and max
class xBoundingBox
{
public:
xPoint min;
xPoint max;
/// return true if p is inside the boundingbox
bool contains(const xPoint &p) const
{
for (int i = 0; i < 3; ++i)
if (min[i] > p[i] || max[i] < p[i]) return false;
return true;
}
/// return true if the boundingbox intersect the othe bounding box, false other wise.
bool cover(const xBoundingBox &otherbb) const
{
for (int i = 0; i < 3; i++)
if (min[i] > otherbb.max[i] || max[i] < otherbb.min[i]) return false;
return true;
}
/// Comparaison between bounding box. return true if both bounding boxes have equal corners.
friend bool operator==(const xBoundingBox &l, const xBoundingBox &r) { return (l.min == r.min && l.max == r.max); }
};
} // namespace xtensor
#endif // XBOUNDINGBOX_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment