Mesh Oriented datABase  (version 5.5.0)
An array-based unstructured mesh library
moab::common_tree Namespace Reference

Classes

class  Box
 
struct  _Element_data
 

Functions

template<typename T , typename Stream >
void print_vector (const T &v, Stream &out)
 
template<typename T >
void print_vector (const T &begin, const T &end)
 
template<typename _Box , typename _Point >
bool box_contains_point (const _Box &box, const _Point &p, const double tol)
 
template<typename _Box >
bool box_contains_box (const _Box &a, const _Box &b, const double tol)
 
template<typename Vector >
void compute_box_center (Vector &max, Vector &min, Vector &center)
 
template<typename Box >
Box::value_type compute_box_center (const Box &box, const int dim)
 
template<typename T >
std::ostream & operator<< (std::ostream &out, const Box< T > &box)
 
template<typename Entities , typename Iterator >
void assign_entities (Entities &entities, const Iterator &begin, const Iterator &end)
 
template<typename Coordinate , typename Coordinate_iterator >
void update_bounding_max (Coordinate &max, Coordinate_iterator j)
 
template<typename Coordinate , typename Coordinate_iterator >
void update_bounding_min (Coordinate &min, Coordinate_iterator j)
 
template<typename Box >
void update_bounding_box (Box &a, const Box &b)
 
template<typename Entity_map , typename Ordering >
void construct_ordering (Entity_map &entity_map, Ordering &entity_ordering)
 
template<typename Entity_handles , typename Element_map , typename Bounding_box , typename Moab >
void construct_element_map (const Entity_handles &elements, Element_map &map, Bounding_box &bounding_box, Moab &moab)
 

Function Documentation

◆ assign_entities()

template<typename Entities , typename Iterator >
void moab::common_tree::assign_entities ( Entities &  entities,
const Iterator &  begin,
const Iterator &  end 
)

Definition at line 171 of file common_tree.hpp.

172  {
173  entities.reserve( std::distance( begin, end ) );
174  for( Iterator i = begin; i != end; ++i )
175  {
176  entities.push_back( std::make_pair( ( *i )->second.first, ( *i )->first ) );
177  }
178  }

References entities.

Referenced by moab::Bvh_tree< _Entity_handles, _Box, _Moab, _Parametrizer >::build_tree(), and moab::Element_tree< _Entity_handles, _Box, _Moab, _Parametrizer >::build_tree().

◆ box_contains_box()

template<typename _Box >
bool moab::common_tree::box_contains_box ( const _Box &  a,
const _Box &  b,
const double  tol 
)

◆ box_contains_point()

template<typename _Box , typename _Point >
bool moab::common_tree::box_contains_point ( const _Box &  box,
const _Point &  p,
const double  tol 
)

Definition at line 61 of file common_tree.hpp.

62  {
63  for( std::size_t i = 0; i < box.min.size(); ++i )
64  {
65  if( p[i] < ( box.min[i] - tol ) || p[i] > ( box.max[i] ) + tol )
66  {
67  return false;
68  }
69  }
70  return true;
71  }

Referenced by moab::Bvh_tree< _Entity_handles, _Box, _Moab, _Parametrizer >::_find_point(), moab::Element_tree< _Entity_handles, _Box, _Moab, _Parametrizer >::_find_point(), and moab::Bvh_tree< _Entity_handles, _Box, _Moab, _Parametrizer >::bruteforce_find().

◆ compute_box_center() [1/2]

template<typename Box >
Box::value_type moab::common_tree::compute_box_center ( const Box box,
const int  dim 
)
inline

Definition at line 116 of file common_tree.hpp.

117  {
118  return ( box.max[dim] + box.min[dim] ) / 2.0;
119  }

References dim, moab::common_tree::Box< T >::max, and moab::common_tree::Box< T >::min.

◆ compute_box_center() [2/2]

template<typename Vector >
void moab::common_tree::compute_box_center ( Vector &  max,
Vector &  min,
Vector &  center 
)
inline

Definition at line 108 of file common_tree.hpp.

109  {
110  typedef typename Vector::value_type Unit;
111  center = min;
112  std::transform( max.begin(), max.end(), center.begin(), center.begin(), Compute_center< Unit >() );
113  }

References center().

Referenced by moab::Bvh_tree< _Entity_handles, _Box, _Moab, _Parametrizer >::median_order().

◆ construct_element_map()

template<typename Entity_handles , typename Element_map , typename Bounding_box , typename Moab >
void moab::common_tree::construct_element_map ( const Entity_handles &  elements,
Element_map &  map,
Bounding_box &  bounding_box,
Moab &  moab 
)

Definition at line 229 of file common_tree.hpp.

233  {
234  typedef typename Element_map::mapped_type Box_data;
235  typedef typename Entity_handles::value_type Entity_handle;
236  typedef typename Entity_handles::iterator Entity_handles_iterator;
237  typedef typename Box_data::first_type::value_type Unit;
238  typedef typename std::vector< Unit > Coordinates;
239  typedef typename Coordinates::iterator Coordinate_iterator;
240 
241  for( Entity_handles_iterator i = elements.begin(); i != elements.end(); ++i )
242  {
243  // TODO: not generic enough. Why dim != 3
244  const int DIM = 3;
245  int num_vertices = 0;
246  // Commence un-necessary deep copying.
247  const Entity_handle* vertex_handle;
248  moab.get_connectivity( *i, vertex_handle, num_vertices );
249  Coordinates coordinate( DIM * num_vertices, 0.0 );
250  moab.get_coords( vertex_handle, num_vertices, &coordinate[0] );
251  Bounding_box box( coordinate.begin(), coordinate.begin() + 3 );
252  if( i == elements.begin() )
253  {
254  bounding_box = box;
255  }
256  for( Coordinate_iterator j = coordinate.begin() + DIM; j != coordinate.end(); j += DIM )
257  {
258  update_bounding_max( box.max, j );
259  update_bounding_min( box.min, j );
260  }
262  map.insert( std::make_pair( *i, Box_data( box ) ) );
263  }
264  }

References bounding_box, update_bounding_box(), update_bounding_max(), and update_bounding_min().

Referenced by moab::Bvh_tree< _Entity_handles, _Box, _Moab, _Parametrizer >::Bvh_tree(), and moab::Element_tree< _Entity_handles, _Box, _Moab, _Parametrizer >::Element_tree().

◆ construct_ordering()

template<typename Entity_map , typename Ordering >
void moab::common_tree::construct_ordering ( Entity_map &  entity_map,
Ordering &  entity_ordering 
)

Definition at line 214 of file common_tree.hpp.

215  {
216  entity_ordering.reserve( entity_map.size() );
217  typedef typename Entity_map::iterator Map_iterator;
218  for( Map_iterator i = entity_map.begin(); i != entity_map.end(); ++i )
219  {
220  entity_ordering.push_back( i );
221  }
222  }

Referenced by moab::Bvh_tree< _Entity_handles, _Box, _Moab, _Parametrizer >::Bvh_tree().

◆ operator<<()

template<typename T >
std::ostream& moab::common_tree::operator<< ( std::ostream &  out,
const Box< T > &  box 
)

Definition at line 144 of file common_tree.hpp.

145  {
146  out << "Max: ";
147  print_vector( box.max, out );
148  out << "Min: ";
149  print_vector( box.min, out );
150  return out;
151  }

References moab::common_tree::Box< T >::max, moab::common_tree::Box< T >::min, and print_vector().

◆ print_vector() [1/2]

template<typename T >
void moab::common_tree::print_vector ( const T begin,
const T end 
)

Definition at line 45 of file common_tree.hpp.

46  {
47  std::cout << "[ ";
48  for( T i = begin; i != end; ++i )
49  {
50  std::cout << ( *i )->second.second.to_ulong();
51  if( i + 1 != end )
52  {
53  std::cout << ", ";
54  }
55  }
56  std::cout << " ]" << std::endl;
57  }

References T.

◆ print_vector() [2/2]

template<typename T , typename Stream >
void moab::common_tree::print_vector ( const T v,
Stream &  out 
)

Definition at line 28 of file common_tree.hpp.

29  {
30  typedef typename T::const_iterator Iterator;
31  out << "[ ";
32  for( Iterator i = v.begin(); i != v.end(); ++i )
33  {
34  out << *i;
35  if( i + 1 != v.end() )
36  {
37  out << ", ";
38  }
39  }
40  out << " ]" << std::endl;
41  }

Referenced by moab::Element_tree< _Entity_handles, _Box, _Moab, _Parametrizer >::compute_split(), moab::Element_tree< _Entity_handles, _Box, _Moab, _Parametrizer >::determine_split(), and operator<<().

◆ update_bounding_box()

◆ update_bounding_max()

template<typename Coordinate , typename Coordinate_iterator >
void moab::common_tree::update_bounding_max ( Coordinate &  max,
Coordinate_iterator  j 
)

Definition at line 181 of file common_tree.hpp.

182  {
183  typedef typename Coordinate::iterator Iterator;
184  for( Iterator i = max.begin(); i != max.end(); ++i, ++j )
185  {
186  *i = std::max( *i, *j );
187  }
188  }

Referenced by construct_element_map(), and update_bounding_box().

◆ update_bounding_min()

template<typename Coordinate , typename Coordinate_iterator >
void moab::common_tree::update_bounding_min ( Coordinate &  min,
Coordinate_iterator  j 
)

Definition at line 191 of file common_tree.hpp.

192  {
193  typedef typename Coordinate::iterator Iterator;
194  for( Iterator i = min.begin(); i != min.end(); ++i, ++j )
195  {
196  *i = std::min( *i, *j );
197  }
198  }

Referenced by construct_element_map(), and update_bounding_box().