MOAB: Mesh Oriented datABase  (version 5.2.1)
MBMesquite::EdgeIterator Class Reference

Iterate over all edges in a patch. More...

#include <EdgeIterator.hpp>

+ Collaboration diagram for MBMesquite::EdgeIterator:


struct  Edge

Public Member Functions

 EdgeIterator (PatchData *patch, MsqError &err)
bool is_at_end () const
const Vector3Dstart () const
const Vector3Dend () const
const Vector3Dmid () const
void step (MsqError &err)

Private Member Functions

void get_adjacent_vertices (MsqError &err)

Private Attributes

size_t vertIdx
std::vector< EdgeadjList
std::vector< Edge >::iterator adjIter

Detailed Description

Iterate over all edges in a patch.

Definition at line 43 of file EdgeIterator.hpp.

Constructor & Destructor Documentation

Definition at line 40 of file EdgeIterator.cpp.

References adjIter, adjList, MBMesquite::PatchData::generate_vertex_to_element_data(), get_adjacent_vertices(), MSQ_ERRRTN, MBMesquite::PatchData::num_nodes(), patchPtr, and step().

                                                        : patchPtr( p ), vertIdx( 0 )
    if( patchPtr->num_nodes() )
        get_adjacent_vertices( err );
        if( adjIter == adjList.end() )
            step( err );MSQ_ERRRTN( err );
        adjIter = adjList.end();

Member Function Documentation

Definition at line 55 of file EdgeIterator.cpp.

References adjIter, adjList, MBMesquite::edges, MBMesquite::PatchData::element_by_index(), MBMesquite::MsqMeshEntity::get_element_type(), MBMesquite::PatchData::get_vertex_element_adjacencies(), MBMesquite::MsqMeshEntity::get_vertex_index(), MBMesquite::MsqMeshEntity::get_vertex_index_array(), MSQ_ERRRTN, MBMesquite::MsqMeshEntity::node_count(), patchPtr, and vertIdx.

Referenced by EdgeIterator(), and step().


    // Get all adjacent elements
    size_t num_elem;
    const size_t* elems = patchPtr->get_vertex_element_adjacencies( vertIdx, num_elem, err );MSQ_ERRRTN( err );

    // Get all adjacent vertices from elements
    std::vector< size_t > elem_verts;
    for( size_t e = 0; e < num_elem; ++e )
        MsqMeshEntity& elem = patchPtr->element_by_index( elems[e] );
        EntityTopology type = elem.get_element_type();
        size_t num_edges    = TopologyInfo::edges( type );

        bool mid_edge, mid_face, mid_vol;
        TopologyInfo::higher_order( type, elem.node_count(), mid_edge, mid_face, mid_vol, err );MSQ_ERRRTN( err );

        // For each edge
        for( size_t d = 0; d < num_edges; ++d )
            const unsigned* edge = TopologyInfo::edge_vertices( type, d, err );MSQ_ERRRTN( err );
            size_t vert1 = elem.get_vertex_index( edge[0] );
            size_t vert2 = elem.get_vertex_index( edge[1] );

            size_t pmid = ~(size_t)0;
            if( mid_edge )
                int p = TopologyInfo::higher_order_from_side( type, elem.node_count(), 1, d, err );MSQ_ERRRTN( err );
                pmid = elem.get_vertex_index_array()[p];

            // If this edge contains the input vertex (vert_idx)
            // AND the input vertex index is less than the
            // other vertex (avoids iterating over this edge twice)
            // add it to the list.
            if( vert1 > vert2 )
                if( vert2 == vertIdx ) adjList.push_back( Edge( vert1, pmid ) );
                if( vert1 == vertIdx ) adjList.push_back( Edge( vert2, pmid ) );

    // Remove duplicates
    std::sort( adjList.begin(), adjList.end() );
    adjIter = std::unique( adjList.begin(), adjList.end() );
    adjList.resize( adjIter - adjList.begin() );
    adjIter = adjList.begin();

Member Data Documentation

std::vector< Edge >::iterator MBMesquite::EdgeIterator::adjIter [private]

Definition at line 65 of file EdgeIterator.hpp.

Referenced by EdgeIterator(), end(), get_adjacent_vertices(), mid(), and step().

std::vector< Edge > MBMesquite::EdgeIterator::adjList [private]

Definition at line 64 of file EdgeIterator.hpp.

Referenced by EdgeIterator(), get_adjacent_vertices(), and step().

Definition at line 63 of file EdgeIterator.hpp.

Referenced by get_adjacent_vertices(), is_at_end(), start(), and step().

List of all members.

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines