LArSoft  v09_90_00
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 145 of file SimpleGeo.h.

Member Typedef Documentation

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

Definition at line 148 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 195 of file SimpleGeo.h.

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

Definition at line 147 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 157 of file SimpleGeo.h.

157 { 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:215

Member Function Documentation

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

Definition at line 161 of file SimpleGeo.h.

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

Definition at line 163 of file SimpleGeo.h.

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

Definition at line 178 of file SimpleGeo.h.

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

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

Definition at line 176 of file SimpleGeo.h.

176 { 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:209
template<typename Point >
void lar::util::simple_geo::AreaBase< Point >::Intersect ( Area_t const &  area)
inline

Definition at line 184 of file SimpleGeo.h.

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

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

Definition at line 168 of file SimpleGeo.h.

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

Definition at line 164 of file SimpleGeo.h.

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

Definition at line 169 of file SimpleGeo.h.

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

Definition at line 166 of file SimpleGeo.h.

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

Definition at line 165 of file SimpleGeo.h.

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

Definition at line 160 of file SimpleGeo.h.

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

Definition at line 159 of file SimpleGeo.h.

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

Definition at line 167 of file SimpleGeo.h.

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

Definition at line 192 of file SimpleGeo.h.

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

192 { 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 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 >
static void lar::util::simple_geo::AreaBase< Point >::set_max ( Data_t var,
Data_t  val 
)
inlinestaticprotected

Definition at line 204 of file SimpleGeo.h.

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

Definition at line 199 of file SimpleGeo.h.

200  {
201  if (val < var) var = val;
202  }
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 209 of file SimpleGeo.h.

210  {
211  set_min(min_var, val);
212  set_max(max_var, val);
213  }
static void set_min(Data_t &var, Data_t val)
Definition: SimpleGeo.h:199
static void set_max(Data_t &var, Data_t val)
Definition: SimpleGeo.h:204
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 215 of file SimpleGeo.h.

216  {
217  if (a > b) {
218  min_var = b;
219  max_var = a;
220  }
221  else {
222  min_var = a;
223  max_var = b;
224  }
225  }
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 174 of file SimpleGeo.h.

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

Definition at line 171 of file SimpleGeo.h.

171 { return DeltaX(); }

Member Data Documentation


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