MOAB: Mesh Oriented datABase  (version 5.2.1)
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 151 of file common_tree.hpp.

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

    {
        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 , typename _Point >
bool moab::common_tree::box_contains_point ( const _Box &  box,
const _Point &  p,
const double  tol 
)

Definition at line 55 of file common_tree.hpp.

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

    {
        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 88 of file common_tree.hpp.

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

    {
        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.

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

    {
        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 206 of file common_tree.hpp.

References 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().

    {
        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 191 of file common_tree.hpp.

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

    {
        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 124 of file common_tree.hpp.

References box(), and print_vector().

    {
        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 28 of file common_tree.hpp.

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

    {
        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 42 of file common_tree.hpp.

References T.

    {
        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 Coordinate , typename Coordinate_iterator >
void moab::common_tree::update_bounding_max ( Coordinate &  max,
Coordinate_iterator  j 
)

Definition at line 161 of file common_tree.hpp.

Referenced by construct_element_map(), and update_bounding_box().

    {
        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 171 of file common_tree.hpp.

Referenced by construct_element_map(), and update_bounding_box().

    {
        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