moab
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

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

Definition at line 147 of file common_tree.hpp.

                                                           {
    entities.reserve( std::distance( begin, end)); 
    for( Iterator i = begin; i != end; ++i){
        entities.push_back( std::make_pair((*i)->second.first, 
                            (*i)->first));
    }
}
template<typename _Box >
bool moab::common_tree::box_contains_box ( const _Box &  a,
const _Box &  b,
const double  tol 
)

Definition at line 65 of file common_tree.hpp.

                                                                         {
    for( std::size_t i = 0; i < a.min.size(); ++i){
         if( b.min[ i] < (a.min[ i]-tol)){
        return false;
          }  
          if( b.max[ i] > (a.max[ i]+tol)){
            return false;
         }
     }
    return true;
}
template<typename _Box , typename _Point >
bool moab::common_tree::box_contains_point ( const _Box &  box,
const _Point &  p,
const double  tol 
)

Definition at line 53 of file common_tree.hpp.

                               {
    for( std::size_t i = 0; i < box.min.size(); ++i){
         if( p[ i] < (box.min[ i]-tol) || 
             p[ i] > (box.max[ i])+tol){
            return false;
         }
     }
    return true;
}
template<typename Vector >
void moab::common_tree::compute_box_center ( Vector &  max,
Vector &  min,
Vector &  center 
) [inline]

Definition at line 87 of file common_tree.hpp.

                                                                           {
    typedef typename Vector::value_type Unit;
    center = min;
    std::transform( max.begin(), max.end(), center.begin(),
            center.begin(), Compute_center< Unit>() );
}
template<typename Box >
Box::value_type moab::common_tree::compute_box_center ( const Box &  box,
const int  dim 
) [inline]

Definition at line 96 of file common_tree.hpp.

                                          {
    return (box.max[ dim] + box.min[ dim])/2.0;
}
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 203 of file common_tree.hpp.

                            {
    typedef typename Element_map::mapped_type Box_data;
    typedef typename Entity_handles::value_type Entity_handle;
    typedef typename Entity_handles::iterator Entity_handles_iterator;
    typedef typename Box_data::first_type::value_type Unit;
    typedef typename std::vector< Unit> Coordinates;
    typedef typename Coordinates::iterator Coordinate_iterator;
        
    for( Entity_handles_iterator i = elements.begin(); 
                     i != elements.end(); ++i){
        //TODO: not generic enough. Why dim != 3
        const int DIM = 3;  
        int num_vertices=0;
        //Commence un-necessary deep copying.
        const Entity_handle* vertex_handle;
        moab.get_connectivity( *i, vertex_handle, num_vertices);
        Coordinates coordinate(DIM*num_vertices, 0.0);
        moab.get_coords( vertex_handle, num_vertices, &coordinate[ 0]);
        Bounding_box box( coordinate.begin(), coordinate.begin()+3);
        if( i == elements.begin() ){ bounding_box = box;}
        for( Coordinate_iterator j = coordinate.begin()+DIM; 
                         j != coordinate.end(); j+=DIM){
            update_bounding_max( box.max, j);
            update_bounding_min( box.min, j);
        }
        update_bounding_box( bounding_box, box);
        map.insert( std::make_pair( *i, Box_data( box)));
    }
}
template<typename Entity_map , typename Ordering >
void moab::common_tree::construct_ordering ( Entity_map &  entity_map,
Ordering &  entity_ordering 
)

Definition at line 185 of file common_tree.hpp.

                                                                             {
    entity_ordering.reserve( entity_map.size());
    typedef typename Entity_map::iterator Map_iterator;
    for(Map_iterator i = entity_map.begin(); 
             i != entity_map.end(); 
             ++i){
        entity_ordering.push_back( i); 
    }
}
template<typename T >
std::ostream& moab::common_tree::operator<< ( std::ostream &  out,
const Box< T > &  box 
)

Definition at line 123 of file common_tree.hpp.

                                                            {
    out << "Max: ";
    print_vector( box.max, out);
    out << "Min: ";
    print_vector( box.min, out);    
    return out;
}
template<typename T , typename Stream >
void moab::common_tree::print_vector ( const T v,
Stream &  out 
)

Definition at line 26 of file common_tree.hpp.

                                             {
    typedef typename T::const_iterator Iterator;
    out << "[ ";
    for(Iterator i = v.begin(); i != v.end(); ++i){
        out << *i;
        if( i+1 != v.end()){
            out << ", ";
        }
    }
    out << " ]" << std::endl;
}
template<typename T >
void moab::common_tree::print_vector ( const T begin,
const T end 
)

Definition at line 40 of file common_tree.hpp.

                                                  {
    std::cout << "[ ";
    for(T i = begin; i != end; ++i){
        std::cout << (*i)->second.second.to_ulong();
        if( i+1 != end){
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
}
template<typename Box >
void moab::common_tree::update_bounding_box ( Box &  a,
const Box &  b 
)

Definition at line 173 of file common_tree.hpp.

                                                 {
    update_bounding_max( a.max, b.max.begin());
    update_bounding_min( a.min, b.min.begin());
    #ifdef COMMON_TREE_DEBUG
    if( !box_contains_box( a, b)){
        std::cout << a << b << std::endl;   
    }
    #endif
}
template<typename Coordinate , typename Coordinate_iterator >
void moab::common_tree::update_bounding_max ( Coordinate &  max,
Coordinate_iterator  j 
)

Definition at line 157 of file common_tree.hpp.

                                                                  {
    typedef typename Coordinate::iterator Iterator;
    for( Iterator i = max.begin(); i != max.end(); ++i, ++j){
        *i = std::max( *i, *j);
    }
}
template<typename Coordinate , typename Coordinate_iterator >
void moab::common_tree::update_bounding_min ( Coordinate &  min,
Coordinate_iterator  j 
)

Definition at line 165 of file common_tree.hpp.

                                                                  {
    typedef typename Coordinate::iterator Iterator;
    for( Iterator i = min.begin(); i != min.end(); ++i, ++j){
        *i = std::min( *i, *j);
    }
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines