shape_doc 0.1
EdgeListBuilder< node_t > Class Template Reference

#include <find_minimal_edges.hpp>

List of all members.

Public Types

Public Member Functions

Protected Member Functions

Protected Attributes


Detailed Description

template<class node_t>
class mmx::shape::EdgeListBuilder< node_t >

Definition at line 34 of file find_minimal_edges.hpp.


Member Typedef Documentation

Definition at line 42 of file find_minimal_edges.hpp.

typedef std::vector<edgeTuple_t> edgeList_t

Definition at line 40 of file find_minimal_edges.hpp.

typedef std::tr1::array<const node_t*, 3> edgeTuple_t

Definition at line 39 of file find_minimal_edges.hpp.

typedef std::vector<faceTuple_t> faceList_t

Definition at line 37 of file find_minimal_edges.hpp.

typedef std::tr1::array<const node_t*, 2> faceTuple_t

Definition at line 36 of file find_minimal_edges.hpp.


Constructor & Destructor Documentation

EdgeListBuilder ( ) [inline]

Definition at line 44 of file find_minimal_edges.hpp.

: m_os( std::cerr ) {}

Member Function Documentation

void cellProc ( const node_t *  n)

Definition at line 230 of file find_minimal_edges.hpp.

                                                                                               {
#ifdef ELB_DEBUG
                        m_os << __FUNCTION__ << n->get_cell()->boundingBox() << std::endl;
#endif

                        if ( n->is_leaf() )
                                return;

                        // Obvious, left and right share a face
                        faceProc( n->left(), n->right(), n->split_dir() );

                        // Obvious
                        cellProc( n->left() );
                        cellProc( n->right() );
                }
bool commonFace ( const faceTuple_t f) const

Return true if two cells share a face.

Definition at line 152 of file find_minimal_edges.hpp.

                                                               {


                        int strict = 0;
                        int nonstrict = 0;

                        for ( int i = 0; i < 3; ++i ) {
                                if ( overlapAlongAxis( f[0], f[1], i, true ) )
                                        strict++;
                                if ( overlapAlongAxis( f[0], f[1], i, false ) )
                                        nonstrict++;
                        }

                        return  ( strict >= 2 && nonstrict >= 3 ) ? true : false;
                }
EdgeListBuilder< node_t >::boundingBox_t computeCommonFace ( const faceTuple_t t) const

Definition at line 168 of file find_minimal_edges.hpp.

References mmx::max(), mmx::min(), bounding_box< C, V >::xmax(), bounding_box< C, V >::xmin(), bounding_box< C, V >::ymax(), bounding_box< C, V >::ymin(), bounding_box< C, V >::zmax(), and bounding_box< C, V >::zmin().

                                                                                                                                                              {

                        using std::min; using std::max;

                        boundingBox_t b0 = f[0]->get_cell()->boundingBox();
                        boundingBox_t b1 = f[1]->get_cell()->boundingBox();

                        boundingBox_t b( max( b0.xmin(), b1.xmin() ),
                                                                                         min( b0.xmax(), b1.xmax() ),
                                                                                         max( b0.ymin(), b1.ymin() ),
                                                                                         min( b0.ymax(), b1.ymax() ),
                                                                                         max( b0.zmin(), b1.zmin() ),
                                                                                         min( b0.zmax(), b1.zmax() ) );

                        return b;
                }
int dist ( const node_t *  n0,
const node_t *  n1 
) const [inline]

Compute the distance in the tree between two nodes.

Definition at line 51 of file find_minimal_edges.hpp.

References abs().

                                                                             {
                                return std::abs( n0->depth() - n1->depth() );
                        }
const edgeList_t& edgeList ( ) const [inline]

Get the computed edgeList.

Definition at line 92 of file find_minimal_edges.hpp.

References EdgeListBuilder< node_t >::m_edgelist.

{ return m_edgelist; }
edgeList_t& edgeList ( ) [inline]

Get the computed edgeList, const version.

Definition at line 95 of file find_minimal_edges.hpp.

References EdgeListBuilder< node_t >::m_edgelist.

{ return m_edgelist; }
void edgeProc ( const node_t *  n0,
const node_t *  n1,
const node_t *  n2,
int  split_dir 
)

Definition at line 325 of file find_minimal_edges.hpp.

                                                                                                              {

#ifdef ELB_DEBUG
                        m_os << __FUNCTION__ << std::endl;
#endif

                        if ( n0->is_leaf() && n1->is_leaf() && n2->is_leaf() ) {
                                edgeTuple_t n = {{ n0, n1, n2 }};
                                m_edgelist.push_back( n );

#ifdef ELB_DEBUG
                                m_os << "Found nodeTuple.\n";
                                for ( int i = 0; i < 3; ++i ) {
                                        m_os << n[i]->get_cell()->boundingBox() << std::endl;
                                }
                                m_os << std::endl;
#endif
                        } else {
                                edgeProc_helper( n0, n1, n2, split_dir );
                                edgeProc_helper( n1, n2, n0, split_dir );
                                edgeProc_helper( n2, n0, n1, split_dir );
                        }
                }
void edgeProc_helper ( const node_t *  n0,
const node_t *  n1,
const node_t *  n2,
int  split_dir 
) [protected]

Definition at line 311 of file find_minimal_edges.hpp.

                                                                                                              {

                        if ( !n0->is_leaf() ) {
                                if ( n0->split_dir() != split_dir ) {
                                        edgeProc( n0->left(),  n1, n2, split_dir );
                                        edgeProc( n0->right(), n1, n2, split_dir );
                                } else { // n0->split_dir() == split_dir
                                        //edgeProc( getChild( n0, getSplitDirParentType( n0, split_dir ) ),
                                        //                                      n1, n2, split_dir );
                                }
                        }
                }
faceList_t& faceList ( ) [inline]

Get the computed edgeList, const version.

Definition at line 101 of file find_minimal_edges.hpp.

References EdgeListBuilder< node_t >::m_facelist.

{ return m_facelist; }
const faceList_t& faceList ( ) const [inline]

Get the computed edgeList.

Definition at line 98 of file find_minimal_edges.hpp.

References EdgeListBuilder< node_t >::m_facelist.

{ return m_facelist; }
bool faceProc ( const node_t *  left,
const node_t *  right,
int  split_dir 
)

Find the common edges of two cells. The cells are assumed to share a face in the v direction, it is the responsibility of the caller to ensure that this is fullfilled.

Definition at line 250 of file find_minimal_edges.hpp.

References mmx::shape_ssi::left(), and mmx::shape_ssi::right().

                                                                                                 {

#ifdef ELB_DEBUG
                        m_os << __FUNCTION__ << std::endl;
                        //                      m_os << left->get_cell()->boundingBox() << std::endl;
                        //                      m_os << right->get_cell()->boundingBox() << std::endl;
#endif

                        // Check that boxes overlap
                        //if ( !overlapAlongAxis( left, right, split_dir ) )
                        //      return false;
                        faceTuple_t f = {{left, right}};
                        if ( !commonFace( f ) )
                                return false;

                        if ( left->is_leaf() && right->is_leaf() ) {
                                faceTuple_t f = {{ left, right }};
#ifdef ELB_DEBUG
                                m_os << "Inserted\n";
                                m_os << left->get_cell()->boundingBox() << std::endl;
                                m_os << right->get_cell()->boundingBox() << std::endl;
#endif

#ifdef ELB_RUNTIME_CHECK
                                if ( std::find( m_facelist.begin(), m_facelist.end(), f )
                                        != m_facelist.end() ) {
                                        m_os << "Face already inserted!\n";

                                        exit(0);
                                }
#endif
                                m_facelist.push_back( f );
                                m_facesplitdir.push_back( split_dir );

                                return true;
                        }

                        // We naively split into both children cells and test for
                        // overlap at the start of the recursive step.
                        if ( !left->is_leaf() ) {
                                if ( left->split_dir() != split_dir ) {
                                        //edgeProc( left->left(), left->right(), right, split_dir );
                                        faceProc( left->left(), right, split_dir );
                                        faceProc( left->right(), right, split_dir );
                                } else { // left->split_dir() == split_dir
                                        faceProc( left->right(), right, split_dir );
                                }
                        } else if ( !right->is_leaf() ) {
                                if ( right->split_dir() != split_dir ) {
                                        //edgeProc( left, right->left(), right->right(), split_dir );
                                        faceProc( left, right->left(), split_dir );
                                        faceProc( left, right->right(), split_dir );
                                } else { // right->split_dir() == split_dir
                                        faceProc( left, right->left(), split_dir );
                                }
                        }

                        return false;
                }
const node_t* getChild ( const node_t *  n,
typename node_t::NODE_TYPE  nt 
) const [inline]

Return either the left or the right child of a node.

Definition at line 56 of file find_minimal_edges.hpp.

                                                                                                     {

                                assert( !n->is_leaf() && "Trying to take children of leaf node." );

                                switch ( nt ) {
                                case node_t::LEFT : return n->left();  break;
                                case node_t::RIGHT: return n->right(); break;
                                default: return 0;
                                }
                        }
node_t::NODE_TYPE getSplitDirParentType ( const node_t *  n,
const int  split_dir 
) const [inline]

Get type of nearest parent which was split in split_dir.

Definition at line 80 of file find_minimal_edges.hpp.

                                                                                                                     {
                                while ( n->parent() != 0 && n->parent()->split_dir() != split_dir ) {
                                        n = n->parent();
                                }
                                if ( n->parent() == 0 )
                                        std::cerr << "Could not find a parent that was split in "
                                                        <<      split_dir << " direction.\n";

                                return n->type();
                        }
bool overlapAlongAxis ( const node_t *  n0,
const node_t *  n1,
int  axis,
bool  strict 
) const

Return true if the extents (boundingboxes) of two nodes has overlap along the given axis.

Definition at line 188 of file find_minimal_edges.hpp.

                                                                                                          {

                        // Intervals for the boundingbox

                        std::tr1::array<double, 2> a, b;

                        switch( axis ) {
                        case 0:
                                a[0] = n0->get_cell()->boundingBox().xmin();
                                b[0] = n1->get_cell()->boundingBox().xmin();
                                a[1] = n0->get_cell()->boundingBox().xmax();
                                b[1] = n1->get_cell()->boundingBox().xmax();
                                break;
                        case 1:
                                a[0] = n0->get_cell()->boundingBox().ymin();
                                b[0] = n1->get_cell()->boundingBox().ymin();
                                a[1] = n0->get_cell()->boundingBox().ymax();
                                b[1] = n1->get_cell()->boundingBox().ymax();
                                break;
                        case 2:
                                a[0] = n0->get_cell()->boundingBox().zmin();
                                b[0] = n1->get_cell()->boundingBox().zmin();
                                a[1] = n0->get_cell()->boundingBox().zmax();
                                b[1] = n1->get_cell()->boundingBox().zmax();
                                break;
                        default:
                                std::cerr << "Trying to take boudningbox along unknown axis!\n";
                                return false;
                        }

                        // Now check the overlap of these intervals
                        // Test taken from overlap method of boost::interval.

                        if ( strict )
                                return ( a[0] <= b[0] && b[0] < a[1] ) ||
                                                         ( b[0] <= a[0] && a[0] < b[1] );
                        else
                                return ( a[0] <= b[0] && b[0] <= a[1] ) ||
                                                         ( b[0] <= a[0] && a[0] <= b[1] );

                }
void verifyFaceList ( ) const

Verify facelist.

Definition at line 112 of file find_minimal_edges.hpp.

References bounding_box< C, V >::xmax(), bounding_box< C, V >::xmin(), bounding_box< C, V >::ymax(), bounding_box< C, V >::ymin(), bounding_box< C, V >::zmax(), and bounding_box< C, V >::zmin().

                                                                                          {
                        size_t errs = 0;
                        for ( size_t i = 0; i < m_facelist.size(); ++i ) {

                                if ( !commonFace( m_facelist[i] ) ) {
                                        errs++;
                                        m_os << "Invalid facetuple found: \n";
                                        m_os << m_facelist[i][0]->get_cell()->boundingBox() << std::endl;
                                        m_os << m_facelist[i][1]->get_cell()->boundingBox() << std::endl;
                                        m_os << m_facelist[i][0]->split_dir() << ", "
                                                        << m_facelist[i][1]->split_dir() << "\n";
                                        m_os << "Split dir: " << m_facesplitdir[i] << std::endl;
                                        const node_t* n0 = m_facelist[i][0];
                                        const node_t* n1 = m_facelist[i][1];

                                        while ( n0->parent() != 0 ) {
                                                m_os << n0->get_cell()->boundingBox() << std::endl;
                                                n0 = n0->parent();
                                        }
                                        m_os << std::endl;
                                        while ( n1->parent() != 0 ) {
                                                m_os << n1->get_cell()->boundingBox() << std::endl;
                                                n1 = n1->parent();
                                        }
                                        exit ( 0 );
                                } else {
                                        m_os << m_facelist[i][0]->get_cell()->boundingBox() << std::endl;
                                        m_os << m_facelist[i][1]->get_cell()->boundingBox() << std::endl;
                                        boundingBox_t c = computeCommonFace( m_facelist[i] );
                                        m_os << "[" << c.xmin() << ", " << c.xmax() << "] x [" << c.ymin() << ", " << c.ymax() << "] x [" << c.zmin() << ", " << c.zmax() << "]\n\n" ;
                                }


                        }

                        m_os << "Errors found: " << errs << " (total " << m_facelist.size() << ")\n";

                }

Member Data Documentation

edgeList_t m_edgelist [protected]

Definition at line 105 of file find_minimal_edges.hpp.

Referenced by EdgeListBuilder< node_t >::edgeList().

faceList_t m_facelist [protected]

Definition at line 106 of file find_minimal_edges.hpp.

Referenced by EdgeListBuilder< node_t >::faceList().

std::vector<int> m_facesplitdir [protected]

Definition at line 107 of file find_minimal_edges.hpp.

std::ostream& m_os [protected]

Definition at line 109 of file find_minimal_edges.hpp.


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