g4tools  5.4.0
Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
tools::box3< VEC3 > Class Template Reference

Public Member Functions

virtual ~box3 ()
 
 box3 (const box3 &a_from)
 
box3operator= (const box3 &a_from)
 
bool center (VEC3 &a_center) const
 
bool set_bounds (const VEC3 &a_mn, const VEC3 &a_mx)
 
bool set_bounds (T_t a_mn_x, T_t a_mn_y, T_t a_mn_z, T_t a_mx_x, T_t a_mx_y, T_t a_mx_z)
 
bool get_size (T_t &a_dx, T_t &a_dy, T_t &a_dz) const
 
bool is_empty () const
 
const VEC3 & mn () const
 
const VEC3 & mx () const
 
bool back (VEC3 &a_min, VEC3 &a_min_y, VEC3 &a_min_xy, VEC3 &a_min_x) const
 
bool front (VEC3 &a_max, VEC3 &a_max_x, VEC3 &a_max_xy, VEC3 &a_max_y) const
 
void extend_by (const VEC3 &a_point)
 
void extend_by (T_t a_x, T_t a_y, T_t a_z)
 
bool get_cube_size (T_t &a_dx, T_t &a_dy, T_t &a_dz, T_t(*a_sqrt)(T_t)) const
 
void dump (std::ostream &a_out)
 

Protected Types

typedef VEC3::elem_t T_t
 

Protected Member Functions

 box3 ()
 

Static Protected Member Functions

static T_t zero ()
 

Protected Attributes

VEC3 m_min
 
VEC3 m_max
 

Detailed Description

template<class VEC3>
class tools::box3< VEC3 >

Definition at line 15 of file box3.

Member Typedef Documentation

◆ T_t

template<class VEC3 >
typedef VEC3::elem_t tools::box3< VEC3 >::T_t
protected

Definition at line 17 of file box3.

Constructor & Destructor Documentation

◆ box3() [1/2]

template<class VEC3 >
tools::box3< VEC3 >::box3 ( )
inlineprotected

Definition at line 21 of file box3.

21  {
22  //make_empty();
23  }

◆ ~box3()

template<class VEC3 >
virtual tools::box3< VEC3 >::~box3 ( )
inlinevirtual

Definition at line 25 of file box3.

25 {}

◆ box3() [2/2]

template<class VEC3 >
tools::box3< VEC3 >::box3 ( const box3< VEC3 > &  a_from)
inline

Definition at line 27 of file box3.

28  :m_min(a_from.m_min)
29  ,m_max(a_from.m_max)
30  {}

Member Function Documentation

◆ back()

template<class VEC3 >
bool tools::box3< VEC3 >::back ( VEC3 &  a_min,
VEC3 &  a_min_y,
VEC3 &  a_min_xy,
VEC3 &  a_min_x 
) const
inline

Definition at line 72 of file box3.

72  {
73  T_t dx,dy,dz;
74  if(!get_size(dx,dy,dz)) return false; //WARNING : a_vecs not touched.
75  // back (from m_min, clockwise order looking toward +z) :
76  a_min = m_min;
77  a_min_y.set_value (m_min.x() ,m_min.y()+dy,m_min.z());
78  a_min_xy.set_value(m_min.x()+dx,m_min.y()+dy,m_min.z());
79  a_min_x.set_value (m_min.x()+dx,m_min.y() ,m_min.z());
80  return true;
81  }

◆ center()

template<class VEC3 >
bool tools::box3< VEC3 >::center ( VEC3 &  a_center) const
inline

Definition at line 37 of file box3.

37  {
38  if(is_empty()) {a_center.set_value(0,0,0);return false;} //??
39  a_center.set_value((m_max[0] + m_min[0])/T_t(2),
40  (m_max[1] + m_min[1])/T_t(2),
41  (m_max[2] + m_min[2])/T_t(2));
42  return true;
43  }

◆ dump()

template<class VEC3 >
void tools::box3< VEC3 >::dump ( std::ostream &  a_out)
inline

Definition at line 148 of file box3.

148  {
149  T_t dx,dy,dz;
150  if(!get_size(dx,dy,dz)) {
151  a_out << "box is empty." << std::endl;
152  } else {
153  a_out << " size " << dx << " " << dy << " " << dz << std::endl;
154  }
155  a_out << " min " << m_min[0] << " " << m_min[1] << " " << m_min[2] << std::endl;
156  a_out << " max " << m_max[0] << " " << m_max[1] << " " << m_max[2] << std::endl;
157  VEC3 c;
158  center(c);
159  a_out << " center " << c[0] << " " << c[1] << " " << c[2] << std::endl;
160  }

◆ extend_by() [1/2]

template<class VEC3 >
void tools::box3< VEC3 >::extend_by ( const VEC3 &  a_point)
inline

Definition at line 94 of file box3.

94  {
95  // Extend the boundaries of the box by the given point, i.e. make the
96  // point fit inside the box if it isn't already so.
97  if(is_empty()) {
98  set_bounds(a_point,a_point);
99  } else {
100  m_min.set_value(min_of<T_t>(a_point[0],m_min[0]),
101  min_of<T_t>(a_point[1],m_min[1]),
102  min_of<T_t>(a_point[2],m_min[2]));
103  m_max.set_value(max_of<T_t>(a_point[0],m_max[0]),
104  max_of<T_t>(a_point[1],m_max[1]),
105  max_of<T_t>(a_point[2],m_max[2]));
106  }
107  }

◆ extend_by() [2/2]

template<class VEC3 >
void tools::box3< VEC3 >::extend_by ( T_t  a_x,
T_t  a_y,
T_t  a_z 
)
inline

Definition at line 109 of file box3.

109  {
110  // Extend the boundaries of the box by the given point, i.e. make the
111  // point fit inside the box if it isn't already so.
112  if(is_empty()) {
113  set_bounds(a_x,a_y,a_z,a_x,a_y,a_z);
114  } else {
115  m_min.set_value(min_of<T_t>(a_x,m_min[0]),
116  min_of<T_t>(a_y,m_min[1]),
117  min_of<T_t>(a_z,m_min[2]));
118  m_max.set_value(max_of<T_t>(a_x,m_max[0]),
119  max_of<T_t>(a_y,m_max[1]),
120  max_of<T_t>(a_z,m_max[2]));
121  }
122  }

◆ front()

template<class VEC3 >
bool tools::box3< VEC3 >::front ( VEC3 &  a_max,
VEC3 &  a_max_x,
VEC3 &  a_max_xy,
VEC3 &  a_max_y 
) const
inline

Definition at line 83 of file box3.

83  {
84  T_t dx,dy,dz;
85  if(!get_size(dx,dy,dz)) return false; //WARNING : a_vecs not touched.
86  // front (from m_max, clockwise order looking toward -z) :
87  a_max = m_max;
88  a_max_x.set_value (m_max.x()-dx,m_max.y() ,m_max.z());
89  a_max_xy.set_value(m_max.x()-dx,m_max.y()-dy,m_max.z());
90  a_max_y.set_value (m_max.x() ,m_max.y()-dy,m_max.z());
91  return true;
92  }

◆ get_cube_size()

template<class VEC3 >
bool tools::box3< VEC3 >::get_cube_size ( T_t a_dx,
T_t a_dy,
T_t a_dz,
T_t(*)(T_t a_sqrt 
) const
inline

Definition at line 124 of file box3.

124  {
125  if(!get_size(a_dx,a_dy,a_dz)) return false;
126  if((a_dx<=zero())&&(a_dy<=zero())&&(a_dz<=zero())) return false;
127  if((a_dx<=zero())&&(a_dy<=zero())) { //dz not 0 :
128  a_dx = T_t(0.1)*a_dz;
129  a_dy = T_t(0.1)*a_dz;
130  } else if((a_dy<=zero())&&(a_dz<=zero())) { //dx not 0 :
131  a_dy = T_t(0.1)*a_dx;
132  a_dz = T_t(0.1)*a_dx;
133  } else if((a_dz<=zero())&&(a_dx<=zero())) { //dy not 0 :
134  a_dz = T_t(0.1)*a_dy;
135  a_dx = T_t(0.1)*a_dy;
136 
137  } else if(a_dx<=zero()) { //dy,dz not 0 :
138  a_dx = T_t(0.1)*a_sqrt(a_dy*a_dy+a_dz*a_dz);
139  } else if(a_dy<=zero()) { //dx,dz not 0 :
140  a_dy = T_t(0.1)*a_sqrt(a_dx*a_dx+a_dz*a_dz);
141  } else if(a_dz<=zero()) { //dx,dy not 0 :
142  a_dz = T_t(0.1)*a_sqrt(a_dx*a_dx+a_dy*a_dy);
143  }
144  return true;
145  }

◆ get_size()

template<class VEC3 >
bool tools::box3< VEC3 >::get_size ( T_t a_dx,
T_t a_dy,
T_t a_dz 
) const
inline

Definition at line 59 of file box3.

59  {
60  if(is_empty()) {a_dx = 0;a_dy = 0;a_dz = 0;return false;}
61  a_dx = m_max[0] - m_min[0];
62  a_dy = m_max[1] - m_min[1];
63  a_dz = m_max[2] - m_min[2];
64  return true;
65  }

◆ is_empty()

template<class VEC3 >
bool tools::box3< VEC3 >::is_empty ( ) const
inline

Definition at line 67 of file box3.

67 {return m_max[0] < m_min[0];}

◆ mn()

template<class VEC3 >
const VEC3& tools::box3< VEC3 >::mn ( ) const
inline

Definition at line 69 of file box3.

69 {return m_min;}

◆ mx()

template<class VEC3 >
const VEC3& tools::box3< VEC3 >::mx ( ) const
inline

Definition at line 70 of file box3.

70 {return m_max;}

◆ operator=()

template<class VEC3 >
box3& tools::box3< VEC3 >::operator= ( const box3< VEC3 > &  a_from)
inline

Definition at line 31 of file box3.

31  {
32  m_min = a_from.m_min;
33  m_max = a_from.m_max;
34  return *this;
35  }

◆ set_bounds() [1/2]

template<class VEC3 >
bool tools::box3< VEC3 >::set_bounds ( const VEC3 &  a_mn,
const VEC3 &  a_mx 
)
inline

Definition at line 45 of file box3.

45  {
46  if( a_mn[0]>a_mx[0] || a_mn[1]>a_mx[1] || a_mn[2]>a_mx[2]) return false;
47  m_min = a_mn;
48  m_max = a_mx;
49  return true;
50  }

◆ set_bounds() [2/2]

template<class VEC3 >
bool tools::box3< VEC3 >::set_bounds ( T_t  a_mn_x,
T_t  a_mn_y,
T_t  a_mn_z,
T_t  a_mx_x,
T_t  a_mx_y,
T_t  a_mx_z 
)
inline

Definition at line 51 of file box3.

52  {
53  if( a_mn_x>a_mx_x || a_mn_y>a_mx_y || a_mn_z>a_mx_z ) return false;
54  m_min.set_value(a_mn_x,a_mn_y,a_mn_z);
55  m_max.set_value(a_mx_x,a_mx_y,a_mx_z);
56  return true;
57  }

◆ zero()

template<class VEC3 >
static T_t tools::box3< VEC3 >::zero ( )
inlinestaticprotected

Definition at line 19 of file box3.

19 {return T_t();}

Member Data Documentation

◆ m_max

template<class VEC3 >
VEC3 tools::box3< VEC3 >::m_max
protected

Definition at line 164 of file box3.

◆ m_min

template<class VEC3 >
VEC3 tools::box3< VEC3 >::m_min
protected

Definition at line 163 of file box3.


The documentation for this class was generated from the following file:
tools::box3::m_max
VEC3 m_max
Definition: box3:164
tools::box3::get_size
bool get_size(T_t &a_dx, T_t &a_dy, T_t &a_dz) const
Definition: box3:59
tools::box3::m_min
VEC3 m_min
Definition: box3:163
tools::box3::is_empty
bool is_empty() const
Definition: box3:67
tools::box3::center
bool center(VEC3 &a_center) const
Definition: box3:37
tools::box3::zero
static T_t zero()
Definition: box3:19
tools::box3::set_bounds
bool set_bounds(const VEC3 &a_mn, const VEC3 &a_mx)
Definition: box3:45
tools::box3::T_t
VEC3::elem_t T_t
Definition: box3:17