LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
lar::util::simple_geo::AreaBase< Point > Class Template Reference

Area/volume delimited by points: base/1D implementation. More...

#include "SimpleGeo.h"

Inheritance diagram for lar::util::simple_geo::AreaBase< Point >:
lar::util::simple_geo::Area< Point > lar::util::simple_geo::Volume< Point >

Classes

class  NullIntersection
 Exception thrown when result of intersection is null. More...
 

Public Types

using Point_t = Point
 
using Area_t = AreaBase< Point >
 

Public Member Functions

 AreaBase ()=default
 
 AreaBase (Point_t const &a, Point_t const &b)
 
Point_t const & Min () const
 
Point_t const & Max () const
 
Point_t Center () const
 
auto DeltaX () const
 
bool isEmptyX () const
 
bool isNullX () const
 
bool isNull () const
 
unsigned int nonEmptyDims () const
 
bool isEmpty () const
 
bool isLine () const
 
auto thinnestSize () const
 
unsigned int thinnestSide () const
 Returns the index of the thinnest side (0 is x) More...
 
void IncludePoint (Point_t const &point)
 
void Include (Area_t const &area)
 
void Intersect (Area_t const &area)
 
bool operator== (Area_t const &as) const
 
bool operator!= (Area_t const &as) const
 

Protected Types

using Data_t = typename Point_t::Data_t
 

Static Protected Member Functions

static void set_min (Data_t &var, Data_t val)
 
static void set_max (Data_t &var, Data_t val)
 
static void set_min_max (Data_t &min_var, Data_t &max_var, Data_t val)
 
static void set_sorted (Data_t &min_var, Data_t &max_var, Data_t a, Data_t b)
 

Protected Attributes

Point_t min
 
Point_t max
 

Detailed Description

template<typename Point>
class lar::util::simple_geo::AreaBase< Point >

Area/volume delimited by points: base/1D implementation.

Definition at line 144 of file SimpleGeo.h.

Member Typedef Documentation

template<typename Point >
using lar::util::simple_geo::AreaBase< Point >::Area_t = AreaBase<Point>

Definition at line 147 of file SimpleGeo.h.

template<typename Point >
using lar::util::simple_geo::AreaBase< Point >::Data_t = typename Point_t::Data_t
protected

Definition at line 194 of file SimpleGeo.h.

template<typename Point >
using lar::util::simple_geo::AreaBase< Point >::Point_t = Point

Definition at line 146 of file SimpleGeo.h.

Constructor & Destructor Documentation

template<typename Point >
lar::util::simple_geo::AreaBase< Point >::AreaBase ( )
default
template<typename Point >
lar::util::simple_geo::AreaBase< Point >::AreaBase ( Point_t const &  a,
Point_t const &  b 
)
inline

Definition at line 156 of file SimpleGeo.h.

156 { set_sorted(min.x, max.x, a.x, b.x); }
static void set_sorted(Data_t &min_var, Data_t &max_var, Data_t a, Data_t b)
Definition: SimpleGeo.h:214

Member Function Documentation

template<typename Point >
Point_t lar::util::simple_geo::AreaBase< Point >::Center ( ) const
inline

Definition at line 160 of file SimpleGeo.h.

160 { return (min + max) * 0.5; }
template<typename Point >
auto lar::util::simple_geo::AreaBase< Point >::DeltaX ( ) const
inline

Definition at line 162 of file SimpleGeo.h.

162 { return Max().x - Min().x; }
Point_t const & Min() const
Definition: SimpleGeo.h:158
Point_t const & Max() const
Definition: SimpleGeo.h:159
template<typename Point >
void lar::util::simple_geo::AreaBase< Point >::Include ( Area_t const &  area)
inline

Definition at line 177 of file SimpleGeo.h.

References lar::util::simple_geo::AreaBase< Point >::max, and lar::util::simple_geo::AreaBase< Point >::min.

178  {
179  IncludePoint(area.min);
180  IncludePoint(area.max);
181  }
void IncludePoint(Point_t const &point)
Definition: SimpleGeo.h:175
template<typename Point >
void lar::util::simple_geo::AreaBase< Point >::IncludePoint ( Point_t const &  point)
inline

Definition at line 175 of file SimpleGeo.h.

175 { set_min_max(min.x, max.x, point.x); }
static void set_min_max(Data_t &min_var, Data_t &max_var, Data_t val)
Definition: SimpleGeo.h:208
template<typename Point >
void lar::util::simple_geo::AreaBase< Point >::Intersect ( Area_t const &  area)
inline

Definition at line 183 of file SimpleGeo.h.

References lar::util::simple_geo::AreaBase< Point >::max, and lar::util::simple_geo::AreaBase< Point >::min.

184  {
185  set_max(min.x, area.min.x);
186  set_min(max.x, area.max.x);
187  if (isNullX()) throw NullIntersection("null x dimension");
188  }
static void set_min(Data_t &var, Data_t val)
Definition: SimpleGeo.h:198
static void set_max(Data_t &var, Data_t val)
Definition: SimpleGeo.h:203
template<typename Point >
bool lar::util::simple_geo::AreaBase< Point >::isEmpty ( ) const
inline

Definition at line 167 of file SimpleGeo.h.

167 { return nonEmptyDims() == 0; }
unsigned int nonEmptyDims() const
Definition: SimpleGeo.h:166
template<typename Point >
bool lar::util::simple_geo::AreaBase< Point >::isEmptyX ( ) const
inline

Definition at line 163 of file SimpleGeo.h.

163 { return (DeltaX() == 0); }
template<typename Point >
bool lar::util::simple_geo::AreaBase< Point >::isLine ( ) const
inline

Definition at line 168 of file SimpleGeo.h.

168 { return nonEmptyDims() == 1; }
unsigned int nonEmptyDims() const
Definition: SimpleGeo.h:166
template<typename Point >
bool lar::util::simple_geo::AreaBase< Point >::isNull ( ) const
inline

Definition at line 165 of file SimpleGeo.h.

165 { return isNullX(); }
template<typename Point >
bool lar::util::simple_geo::AreaBase< Point >::isNullX ( ) const
inline

Definition at line 164 of file SimpleGeo.h.

164 { return Max().x < Min().x; }
Point_t const & Min() const
Definition: SimpleGeo.h:158
Point_t const & Max() const
Definition: SimpleGeo.h:159
template<typename Point >
Point_t const& lar::util::simple_geo::AreaBase< Point >::Max ( ) const
inline

Definition at line 159 of file SimpleGeo.h.

159 { return max; }
template<typename Point >
Point_t const& lar::util::simple_geo::AreaBase< Point >::Min ( ) const
inline

Definition at line 158 of file SimpleGeo.h.

158 { return min; }
template<typename Point >
unsigned int lar::util::simple_geo::AreaBase< Point >::nonEmptyDims ( ) const
inline

Definition at line 166 of file SimpleGeo.h.

166 { return isEmptyX() ? 0 : 1; }
template<typename Point >
bool lar::util::simple_geo::AreaBase< Point >::operator!= ( Area_t const &  as) const
inline

Definition at line 191 of file SimpleGeo.h.

References lar::util::simple_geo::AreaBase< Point >::max, and lar::util::simple_geo::AreaBase< Point >::min.

191 { return (min != as.min) || (max != as.max); }
template<typename Point >
bool lar::util::simple_geo::AreaBase< Point >::operator== ( Area_t const &  as) const
inline

Definition at line 190 of file SimpleGeo.h.

References lar::util::simple_geo::AreaBase< Point >::max, and lar::util::simple_geo::AreaBase< Point >::min.

190 { return (min == as.min) && (max == as.max); }
template<typename Point >
static void lar::util::simple_geo::AreaBase< Point >::set_max ( Data_t var,
Data_t  val 
)
inlinestaticprotected

Definition at line 203 of file SimpleGeo.h.

204  {
205  if (val > var) var = val;
206  }
template<typename Point >
static void lar::util::simple_geo::AreaBase< Point >::set_min ( Data_t var,
Data_t  val 
)
inlinestaticprotected

Definition at line 198 of file SimpleGeo.h.

199  {
200  if (val < var) var = val;
201  }
template<typename Point >
static void lar::util::simple_geo::AreaBase< Point >::set_min_max ( Data_t min_var,
Data_t max_var,
Data_t  val 
)
inlinestaticprotected

Definition at line 208 of file SimpleGeo.h.

209  {
210  set_min(min_var, val);
211  set_max(max_var, val);
212  }
static void set_min(Data_t &var, Data_t val)
Definition: SimpleGeo.h:198
static void set_max(Data_t &var, Data_t val)
Definition: SimpleGeo.h:203
template<typename Point >
static void lar::util::simple_geo::AreaBase< Point >::set_sorted ( Data_t min_var,
Data_t max_var,
Data_t  a,
Data_t  b 
)
inlinestaticprotected

Definition at line 214 of file SimpleGeo.h.

215  {
216  if (a > b) {
217  min_var = b;
218  max_var = a;
219  }
220  else {
221  min_var = a;
222  max_var = b;
223  }
224  }
template<typename Point >
unsigned int lar::util::simple_geo::AreaBase< Point >::thinnestSide ( ) const
inline

Returns the index of the thinnest side (0 is x)

Definition at line 173 of file SimpleGeo.h.

173 { return 0; }
template<typename Point >
auto lar::util::simple_geo::AreaBase< Point >::thinnestSize ( ) const
inline

Definition at line 170 of file SimpleGeo.h.

170 { return DeltaX(); }

Member Data Documentation


The documentation for this class was generated from the following file: