Removed the x(), y(), z() Point/Pointf/Point3/Pointf3 accessors.

This commit is contained in:
bubnikv 2018-08-17 15:53:43 +02:00
parent 1ba64da3fe
commit 65011f9382
60 changed files with 1083 additions and 1111 deletions

View file

@ -27,14 +27,14 @@ BoundingBox::polygon(Polygon* polygon) const
{
polygon->points.clear();
polygon->points.resize(4);
polygon->points[0].x() = this->min.x();
polygon->points[0].y() = this->min.y();
polygon->points[1].x() = this->max.x();
polygon->points[1].y() = this->min.y();
polygon->points[2].x() = this->max.x();
polygon->points[2].y() = this->max.y();
polygon->points[3].x() = this->min.x();
polygon->points[3].y() = this->max.y();
polygon->points[0](0) = this->min(0);
polygon->points[0](1) = this->min(1);
polygon->points[1](0) = this->max(0);
polygon->points[1](1) = this->min(1);
polygon->points[2](0) = this->max(0);
polygon->points[2](1) = this->max(1);
polygon->points[3](0) = this->min(0);
polygon->points[3](1) = this->max(1);
}
Polygon
@ -50,8 +50,8 @@ BoundingBox BoundingBox::rotated(double angle) const
BoundingBox out;
out.merge(this->min.rotated(angle));
out.merge(this->max.rotated(angle));
out.merge(Point(this->min.x(), this->max.y()).rotated(angle));
out.merge(Point(this->max.x(), this->min.y()).rotated(angle));
out.merge(Point(this->min(0), this->max(1)).rotated(angle));
out.merge(Point(this->max(0), this->min(1)).rotated(angle));
return out;
}
@ -60,8 +60,8 @@ BoundingBox BoundingBox::rotated(double angle, const Point &center) const
BoundingBox out;
out.merge(this->min.rotated(angle, center));
out.merge(this->max.rotated(angle, center));
out.merge(Point(this->min.x(), this->max.y()).rotated(angle, center));
out.merge(Point(this->max.x(), this->min.y()).rotated(angle, center));
out.merge(Point(this->min(0), this->max(1)).rotated(angle, center));
out.merge(Point(this->max(0), this->min(1)).rotated(angle, center));
return out;
}
@ -79,10 +79,10 @@ template <class PointClass> void
BoundingBoxBase<PointClass>::merge(const PointClass &point)
{
if (this->defined) {
this->min.x() = std::min(point.x(), this->min.x());
this->min.y() = std::min(point.y(), this->min.y());
this->max.x() = std::max(point.x(), this->max.x());
this->max.y() = std::max(point.y(), this->max.y());
this->min(0) = std::min(point(0), this->min(0));
this->min(1) = std::min(point(1), this->min(1));
this->max(0) = std::max(point(0), this->max(0));
this->max(1) = std::max(point(1), this->max(1));
} else {
this->min = this->max = point;
this->defined = true;
@ -102,13 +102,13 @@ template void BoundingBoxBase<Pointf>::merge(const Pointfs &points);
template <class PointClass> void
BoundingBoxBase<PointClass>::merge(const BoundingBoxBase<PointClass> &bb)
{
assert(bb.defined || bb.min.x() >= bb.max.x() || bb.min.y() >= bb.max.y());
assert(bb.defined || bb.min(0) >= bb.max(0) || bb.min(1) >= bb.max(1));
if (bb.defined) {
if (this->defined) {
this->min.x() = std::min(bb.min.x(), this->min.x());
this->min.y() = std::min(bb.min.y(), this->min.y());
this->max.x() = std::max(bb.max.x(), this->max.x());
this->max.y() = std::max(bb.max.y(), this->max.y());
this->min(0) = std::min(bb.min(0), this->min(0));
this->min(1) = std::min(bb.min(1), this->min(1));
this->max(0) = std::max(bb.max(0), this->max(0));
this->max(1) = std::max(bb.max(1), this->max(1));
} else {
this->min = bb.min;
this->max = bb.max;
@ -123,8 +123,8 @@ template <class PointClass> void
BoundingBox3Base<PointClass>::merge(const PointClass &point)
{
if (this->defined) {
this->min.z() = std::min(point.z(), this->min.z());
this->max.z() = std::max(point.z(), this->max.z());
this->min(2) = std::min(point(2), this->min(2));
this->max(2) = std::max(point(2), this->max(2));
}
BoundingBoxBase<PointClass>::merge(point);
}
@ -140,11 +140,11 @@ template void BoundingBox3Base<Pointf3>::merge(const Pointf3s &points);
template <class PointClass> void
BoundingBox3Base<PointClass>::merge(const BoundingBox3Base<PointClass> &bb)
{
assert(bb.defined || bb.min.x() >= bb.max.x() || bb.min.y() >= bb.max.y() || bb.min.z() >= bb.max.z());
assert(bb.defined || bb.min(0) >= bb.max(0) || bb.min(1) >= bb.max(1) || bb.min(2) >= bb.max(2));
if (bb.defined) {
if (this->defined) {
this->min.z() = std::min(bb.min.z(), this->min.z());
this->max.z() = std::max(bb.max.z(), this->max.z());
this->min(2) = std::min(bb.min(2), this->min(2));
this->max(2) = std::max(bb.max(2), this->max(2));
}
BoundingBoxBase<PointClass>::merge(bb);
}
@ -154,7 +154,7 @@ template void BoundingBox3Base<Pointf3>::merge(const BoundingBox3Base<Pointf3> &
template <class PointClass> PointClass
BoundingBoxBase<PointClass>::size() const
{
return PointClass(this->max.x() - this->min.x(), this->max.y() - this->min.y());
return PointClass(this->max(0) - this->min(0), this->max(1) - this->min(1));
}
template Point BoundingBoxBase<Point>::size() const;
template Pointf BoundingBoxBase<Pointf>::size() const;
@ -162,15 +162,15 @@ template Pointf BoundingBoxBase<Pointf>::size() const;
template <class PointClass> PointClass
BoundingBox3Base<PointClass>::size() const
{
return PointClass(this->max.x() - this->min.x(), this->max.y() - this->min.y(), this->max.z() - this->min.z());
return PointClass(this->max(0) - this->min(0), this->max(1) - this->min(1), this->max(2) - this->min(2));
}
template Pointf3 BoundingBox3Base<Pointf3>::size() const;
template <class PointClass> double BoundingBoxBase<PointClass>::radius() const
{
assert(this->defined);
double x = this->max.x() - this->min.x();
double y = this->max.y() - this->min.y();
double x = this->max(0) - this->min(0);
double y = this->max(1) - this->min(1);
return 0.5 * sqrt(x*x+y*y);
}
template double BoundingBoxBase<Point>::radius() const;
@ -178,9 +178,9 @@ template double BoundingBoxBase<Pointf>::radius() const;
template <class PointClass> double BoundingBox3Base<PointClass>::radius() const
{
double x = this->max.x() - this->min.x();
double y = this->max.y() - this->min.y();
double z = this->max.z() - this->min.z();
double x = this->max(0) - this->min(0);
double y = this->max(1) - this->min(1);
double z = this->max(2) - this->min(2);
return 0.5 * sqrt(x*x+y*y+z*z);
}
template double BoundingBox3Base<Pointf3>::radius() const;
@ -208,8 +208,8 @@ template <class PointClass> PointClass
BoundingBoxBase<PointClass>::center() const
{
return PointClass(
(this->max.x() + this->min.x())/2,
(this->max.y() + this->min.y())/2
(this->max(0) + this->min(0))/2,
(this->max(1) + this->min(1))/2
);
}
template Point BoundingBoxBase<Point>::center() const;
@ -219,9 +219,9 @@ template <class PointClass> PointClass
BoundingBox3Base<PointClass>::center() const
{
return PointClass(
(this->max.x() + this->min.x())/2,
(this->max.y() + this->min.y())/2,
(this->max.z() + this->min.z())/2
(this->max(0) + this->min(0))/2,
(this->max(1) + this->min(1))/2,
(this->max(2) + this->min(2))/2
);
}
template Pointf3 BoundingBox3Base<Pointf3>::center() const;
@ -230,7 +230,7 @@ template <class PointClass> coordf_t
BoundingBox3Base<PointClass>::max_size() const
{
PointClass s = size();
return std::max(s.x(), std::max(s.y(), s.z()));
return std::max(s(0), std::max(s(1), s(2)));
}
template coordf_t BoundingBox3Base<Pointf3>::max_size() const;
@ -250,8 +250,8 @@ static inline coord_t _align_to_grid(const coord_t coord, const coord_t spacing)
void BoundingBox::align_to_grid(const coord_t cell_size)
{
if (this->defined) {
min.x() = _align_to_grid(min.x(), cell_size);
min.y() = _align_to_grid(min.y(), cell_size);
min(0) = _align_to_grid(min(0), cell_size);
min(1) = _align_to_grid(min(1), cell_size);
}
}
@ -259,14 +259,14 @@ BoundingBoxf3 BoundingBoxf3::transformed(const Transform3f& matrix) const
{
Eigen::Matrix<float, 3, 8, Eigen::DontAlign> vertices;
vertices(0, 0) = (float)min.x(); vertices(1, 0) = (float)min.y(); vertices(2, 0) = (float)min.z();
vertices(0, 1) = (float)max.x(); vertices(1, 1) = (float)min.y(); vertices(2, 1) = (float)min.z();
vertices(0, 2) = (float)max.x(); vertices(1, 2) = (float)max.y(); vertices(2, 2) = (float)min.z();
vertices(0, 3) = (float)min.x(); vertices(1, 3) = (float)max.y(); vertices(2, 3) = (float)min.z();
vertices(0, 4) = (float)min.x(); vertices(1, 4) = (float)min.y(); vertices(2, 4) = (float)max.z();
vertices(0, 5) = (float)max.x(); vertices(1, 5) = (float)min.y(); vertices(2, 5) = (float)max.z();
vertices(0, 6) = (float)max.x(); vertices(1, 6) = (float)max.y(); vertices(2, 6) = (float)max.z();
vertices(0, 7) = (float)min.x(); vertices(1, 7) = (float)max.y(); vertices(2, 7) = (float)max.z();
vertices(0, 0) = (float)min(0); vertices(1, 0) = (float)min(1); vertices(2, 0) = (float)min(2);
vertices(0, 1) = (float)max(0); vertices(1, 1) = (float)min(1); vertices(2, 1) = (float)min(2);
vertices(0, 2) = (float)max(0); vertices(1, 2) = (float)max(1); vertices(2, 2) = (float)min(2);
vertices(0, 3) = (float)min(0); vertices(1, 3) = (float)max(1); vertices(2, 3) = (float)min(2);
vertices(0, 4) = (float)min(0); vertices(1, 4) = (float)min(1); vertices(2, 4) = (float)max(2);
vertices(0, 5) = (float)max(0); vertices(1, 5) = (float)min(1); vertices(2, 5) = (float)max(2);
vertices(0, 6) = (float)max(0); vertices(1, 6) = (float)max(1); vertices(2, 6) = (float)max(2);
vertices(0, 7) = (float)min(0); vertices(1, 7) = (float)max(1); vertices(2, 7) = (float)max(2);
Eigen::Matrix<float, 3, 8, Eigen::DontAlign> transf_vertices = matrix * vertices.colwise().homogeneous();