From f85e3765dbd47c421b9105ae50936e6e6d003dd4 Mon Sep 17 00:00:00 2001 From: Peter Keresztes Schmidt Date: Sun, 2 May 2021 23:03:58 +0200 Subject: [PATCH] Box: Remove unnecessary constructors --- src/zm_box.h | 16 +++++++--------- src/zm_poly.cpp | 2 +- src/zm_stream.cpp | 2 +- src/zm_zone_stats.h | 7 +------ 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/zm_box.h b/src/zm_box.h index a25b09991..5799eb898 100644 --- a/src/zm_box.h +++ b/src/zm_box.h @@ -28,16 +28,9 @@ // defined by two coordinates // class Box { - private: - Vector2 lo, hi; - Vector2 size; - public: - inline Box() : lo(0, 0), hi(0, 0), size(0, 0) {} - explicit inline Box(unsigned int p_size) : lo(0, 0), hi(p_size - 1, p_size - 1), size(Vector2::Range(hi, lo)) {} - inline Box(int p_x_size, int p_y_size) : lo(0, 0), hi(p_x_size - 1, p_y_size - 1), size(Vector2::Range(hi, lo)) {} - inline Box(int lo_x, int lo_y, int hi_x, int hi_y) : lo(lo_x, lo_y), hi(hi_x, hi_y), size(Vector2::Range(hi, lo)) {} - inline Box(const Vector2 &p_lo, const Vector2 &p_hi) : lo(p_lo), hi(p_hi), size(Vector2::Range(hi, lo)) {} + Box() = default; + Box(Vector2 p_lo, Vector2 p_hi) : lo(p_lo), hi(p_hi), size(Vector2::Range(hi, lo)) {} inline const Vector2 &Lo() const { return lo; } inline int LoX() const { return lo.x_; } @@ -62,6 +55,11 @@ class Box { inline bool Inside(const Vector2 &coord) const { return (coord.x_ >= lo.x_ && coord.x_ <= hi.x_ && coord.y_ >= lo.y_ && coord.y_ <= hi.y_); } + + private: + Vector2 lo; + Vector2 hi; + Vector2 size; }; #endif // ZM_BOX_H diff --git a/src/zm_poly.cpp b/src/zm_poly.cpp index a1fba9e48..8f52ff14e 100644 --- a/src/zm_poly.cpp +++ b/src/zm_poly.cpp @@ -62,7 +62,7 @@ Polygon::Polygon(int p_n_coords, const Vector2 *p_coords) : n_coords(p_n_coords) if (max_y == -1 || coords[i].y_ > max_y) max_y = coords[i].y_; } - extent = Box(min_x, min_y, max_x, max_y); + extent = Box({min_x, min_y}, {max_x, max_y}); calcArea(); calcCentre(); } diff --git a/src/zm_stream.cpp b/src/zm_stream.cpp index 0968c9514..974ca47cd 100644 --- a/src/zm_stream.cpp +++ b/src/zm_stream.cpp @@ -231,7 +231,7 @@ Image *StreamBase::prepareImage(Image *image) { hi_y = act_image_height - 1; lo_y = hi_y - (send_image_height - 1); } - last_crop = Box( lo_x, lo_y, hi_x, hi_y ); + last_crop = Box({lo_x, lo_y}, {hi_x, hi_y}); } // end if ( mag != last_mag || x != last_x || y != last_y ) Debug(3, "Cropping to %d,%d -> %d,%d", last_crop.LoX(), last_crop.LoY(), last_crop.HiX(), last_crop.HiY()); diff --git a/src/zm_zone_stats.h b/src/zm_zone_stats.h index 9d3ab7cef..5cc20a5db 100644 --- a/src/zm_zone_stats.h +++ b/src/zm_zone_stats.h @@ -35,8 +35,6 @@ class ZoneStats { alarm_blobs_(0), min_blob_size_(0), max_blob_size_(0), - alarm_box_({}), - alarm_centre_({}), score_(0) {}; void Reset() { @@ -47,10 +45,7 @@ class ZoneStats { alarm_blobs_ = 0; min_blob_size_ = 0; max_blob_size_ = 0; - alarm_box_.LoX(0); - alarm_box_.LoY(0); - alarm_box_.HiX(0); - alarm_box_.HiY(0); + alarm_box_ = {}; alarm_centre_ = {}; score_ = 0; }