24 "A general transform of a ccBBox would not be axis "
25 "aligned anymore, convert it to a OrientedBoundingBox first");
31 m_bbMin += translation;
32 m_bbMax += translation;
34 const Eigen::Vector3d half_extent = GetHalfExtent();
48 const Eigen::Vector3d& center) {
50 "A rotation of a ccBBox would not be axis aligned "
51 "anymore, convert it to an ecvOrientedBBox first");
59 this->setValidity(
true);
63 this->setValidity(
true);
105 [](
const Eigen::Vector3d&
a,
const Eigen::Vector3d& b) {
106 return a.array().min(b.array()).matrix();
110 [](
const Eigen::Vector3d&
a,
const Eigen::Vector3d& b) {
111 return a.array().max(b.array()).matrix();
120 std::vector<Eigen::Vector3d>
points(8);
121 Eigen::Vector3d extent = GetExtent();
125 points[1] = min_bound + Eigen::Vector3d(extent(0), 0, 0);
126 points[2] = min_bound + Eigen::Vector3d(0, extent(1), 0);
127 points[3] = min_bound + Eigen::Vector3d(0, 0, extent(2));
129 points[5] = max_bound - Eigen::Vector3d(extent(0), 0, 0);
130 points[6] = max_bound - Eigen::Vector3d(0, extent(1), 0);
131 points[7] = max_bound - Eigen::Vector3d(0, 0, extent(2));
136 return fmt::format(
"[({:.4f}, {:.4f}, {:.4f}) - ({:.4f}, {:.4f}, {:.4f})]",
137 m_bbMin(0), m_bbMin(1), m_bbMin(2), m_bbMax(0),
138 m_bbMax(1), m_bbMax(2));
145 rotatedBox.
add(mat * m_bbMin);
146 rotatedBox.
add(mat *
CCVector3(m_bbMin.x, m_bbMin.y, m_bbMax.z));
147 rotatedBox.
add(mat *
CCVector3(m_bbMin.x, m_bbMax.y, m_bbMin.z));
148 rotatedBox.
add(mat *
CCVector3(m_bbMax.x, m_bbMin.y, m_bbMin.z));
149 rotatedBox.
add(mat * m_bbMax);
150 rotatedBox.
add(mat *
CCVector3(m_bbMin.x, m_bbMax.y, m_bbMax.z));
151 rotatedBox.
add(mat *
CCVector3(m_bbMax.x, m_bbMax.y, m_bbMin.z));
152 rotatedBox.
add(mat *
CCVector3(m_bbMax.x, m_bbMin.y, m_bbMax.z));
162 rotatedBox.
add(mat * m_bbMin);
163 rotatedBox.
add(mat *
CCVector3(m_bbMin.x, m_bbMin.y, m_bbMax.z));
164 rotatedBox.
add(mat *
CCVector3(m_bbMin.x, m_bbMax.y, m_bbMin.z));
165 rotatedBox.
add(mat *
CCVector3(m_bbMax.x, m_bbMin.y, m_bbMin.z));
166 rotatedBox.
add(mat * m_bbMax);
167 rotatedBox.
add(mat *
CCVector3(m_bbMin.x, m_bbMax.y, m_bbMax.z));
168 rotatedBox.
add(mat *
CCVector3(m_bbMax.x, m_bbMax.y, m_bbMin.z));
169 rotatedBox.
add(mat *
CCVector3(m_bbMax.x, m_bbMin.y, m_bbMax.z));
202 boxCorners[0] = m_bbMin;
203 boxCorners[1] =
CCVector3(m_bbMin.x, m_bbMin.y, m_bbMax.z);
204 boxCorners[2] =
CCVector3(m_bbMin.x, m_bbMax.y, m_bbMin.z);
205 boxCorners[3] =
CCVector3(m_bbMax.x, m_bbMin.y, m_bbMin.z);
206 boxCorners[4] = m_bbMax;
207 boxCorners[5] =
CCVector3(m_bbMin.x, m_bbMax.y, m_bbMax.z);
208 boxCorners[6] =
CCVector3(m_bbMax.x, m_bbMax.y, m_bbMin.z);
209 boxCorners[7] =
CCVector3(m_bbMax.x, m_bbMin.y, m_bbMax.z);
213 for (
int i = 0; i < 8; ++i) {
214 add(mat * boxCorners[i]);
251 boxCorners[0] = m_bbMin;
252 boxCorners[1] =
CCVector3(m_bbMin.x, m_bbMin.y, m_bbMax.z);
253 boxCorners[2] =
CCVector3(m_bbMin.x, m_bbMax.y, m_bbMin.z);
254 boxCorners[3] =
CCVector3(m_bbMax.x, m_bbMin.y, m_bbMin.z);
255 boxCorners[4] = m_bbMax;
256 boxCorners[5] =
CCVector3(m_bbMin.x, m_bbMax.y, m_bbMax.z);
257 boxCorners[6] =
CCVector3(m_bbMax.x, m_bbMax.y, m_bbMin.z);
258 boxCorners[7] =
CCVector3(m_bbMax.x, m_bbMin.y, m_bbMax.z);
264 for (
int i = 0; i < 8; ++i) {
265 add(tempMat * boxCorners[i]);
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
float PointCoordinateType
Type of the coordinates of a (N-D) point.
filament::Texture::InternalFormat format
static Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
const ccBBox operator*(const ccGLMatrix &mat)
Applies transformation to the bounding box.
void draw(CC_DRAW_CONTEXT &context) override
Draws entity and its children.
PointCoordinateType GetMaxExtent() const
virtual ccBBox & Rotate(const Eigen::Matrix3d &R, const Eigen::Vector3d ¢er) override
Apply rotation to the geometry coordinates and normals. Given a rotation matrix , and center ,...
static ccBBox CreateFromPoints(const std::vector< CCVector3 > &points)
const ccBBox & operator+=(const ccBBox &other)
std::string GetPrintInfo() const
Returns the 3D dimensions of the bounding box in string format.
const ccBBox & operator-=(const CCVector3 &V) override
virtual ccBBox & Translate(const Eigen::Vector3d &translation, bool relative=true) override
Apply translation to the geometry coordinates.
virtual ccBBox & Transform(const Eigen::Matrix4d &transformation) override
Apply transformation (4x4 matrix) to the geometry coordinates.
virtual ccBBox & Scale(const double s, const Eigen::Vector3d ¢er) override
Apply scaling to the geometry coordinates. Given a scaling factor , and center , a given point is tr...
std::vector< Eigen::Vector3d > GetBoxPoints() const
Returns the eight points that define the bounding box.
virtual ecvOrientedBBox GetOrientedBoundingBox() const override
const ccBBox & operator*=(float scaleFactor) override
Scales the bounding box.
virtual bool IsEmpty() const override
Float version of ccGLMatrixTpl.
Double version of ccGLMatrixTpl.
const Vector3Tpl< T > & maxCorner() const
Returns max corner (const)
void setValidity(bool state)
Sets bonding box validity.
const Vector3Tpl< T > & minCorner() const
Returns min corner (const)
void add(const Vector3Tpl< T > &P)
'Enlarges' the bounding box with a point
static ecvOrientedBBox CreateFromAxisAlignedBoundingBox(const ccBBox &aabox)
Generic file read and write utility for python interface.