MOAB: Mesh Oriented datABase  (version 5.4.1)
MBMesquite::MeshImplData Class Reference

#include <MeshImplData.hpp>

Classes

struct  Element
struct  Vertex

Public Member Functions

 MeshImplData ()
void clear ()
size_t num_vertices () const
size_t num_elements () const
size_t num_vertex_uses () const
size_t max_vertex_index () const
size_t max_element_index () const
void copy_mesh (size_t *vertex_handle_array, size_t *element_hanlde_array, size_t *element_conn_offsets, size_t *element_conn_indices)
void all_vertices (std::vector< size_t > &list, MsqError &err) const
void all_elements (std::vector< size_t > &list, MsqError &err) const
bool is_vertex_valid (size_t index) const
bool is_element_valid (size_t index) const
bool is_mid_node (size_t index) const
bool is_corner_node (size_t index) const
const Vector3Dget_vertex_coords (size_t index, MsqError &err) const
void set_vertex_coords (size_t index, const Vector3D &coords, MsqError &err)
bool vertex_is_fixed (size_t index, MsqError &err) const
bool vertex_is_slaved (size_t index, MsqError &err) const
void fix_vertex (size_t index, bool flag, MsqError &err)
void slave_vertex (size_t index, bool flag, MsqError &err)
unsigned char get_vertex_byte (size_t index, MsqError &err) const
void set_vertex_byte (size_t index, unsigned char value, MsqError &err)
EntityTopology element_topology (size_t index, MsqError &err) const
void element_topology (size_t index, EntityTopology type, MsqError &err)
const std::vector< size_t > & element_connectivity (size_t index, MsqError &err) const
const std::vector< size_t > & vertex_adjacencies (size_t index, MsqError &err) const
void allocate_vertices (size_t count, MsqError &err)
void allocate_elements (size_t count, MsqError &err)
void reset_vertex (size_t index, const Vector3D &coords, bool fixed, MsqError &err)
void reset_element (size_t index, const std::vector< long > &vertices, EntityTopology topology, MsqError &err)
void reset_element (size_t index, const std::vector< size_t > &vertices, EntityTopology topology, MsqError &err)
size_t add_vertex (const Vector3D &coords, bool fixed, MsqError &err)
size_t add_element (const std::vector< long > &vertices, EntityTopology topology, MsqError &err)
size_t add_element (const std::vector< size_t > &vertices, EntityTopology topology, MsqError &err)
void delete_vertex (size_t index, MsqError &err)
void delete_element (size_t index, MsqError &err)
void copy_higher_order (std::vector< size_t > &mid_nodes, std::vector< size_t > &vertices, std::vector< size_t > &vertex_indices, std::vector< size_t > &index_offsets, MsqError &err)
void get_adjacent_elements (std::vector< size_t >::const_iterator nodes, std::vector< size_t >::const_iterator nodes_end, std::vector< size_t > &elems_out, MsqError &err)
 Get elements adjacent to ALL of the passed nodes.
void skin (std::vector< size_t > &sides, MsqError &err)
 Skin mesh.
bool have_slaved_flags () const

Private Member Functions

bool has_adjacent_elements (size_t elem, const std::vector< size_t > &nodes, MsqError &err)
 helper function for skinning
void clear_element (size_t index, MsqError &err)
void set_element (size_t index, const std::vector< long > &vertices, EntityTopology topology, MsqError &err)
void set_element (size_t index, const std::vector< size_t > &vertices, EntityTopology topology, MsqError &err)

Private Attributes

std::vector< VertexvertexList
std::vector< ElementelementList
std::vector< size_t > deletedVertexList
std::vector< size_t > deletedElementList
bool haveSlavedFlags

Detailed Description

Class to store mesh representation for MeshImpl

Definition at line 43 of file MeshImplData.hpp.


Constructor & Destructor Documentation

Definition at line 47 of file MeshImplData.hpp.

: haveSlavedFlags( false ) {}

Member Function Documentation

size_t MBMesquite::MeshImplData::add_element ( const std::vector< long > &  vertices,
EntityTopology  topology,
MsqError err 
)

Add a new element

Definition at line 393 of file MeshImplData.cpp.

References deletedElementList, elementList, MSQ_ERRZERO, and set_element().

{
    size_t index;
    if( !deletedElementList.empty() )
    {
        index = deletedElementList[deletedElementList.size() - 1];
        deletedElementList.pop_back();
    }
    else
    {
        index = elementList.size();
        elementList.resize( elementList.size() + 1 );
    }

    set_element( index, vertices, topology, err );
    MSQ_ERRZERO( err );
    return index;
}
size_t MBMesquite::MeshImplData::add_element ( const std::vector< size_t > &  vertices,
EntityTopology  topology,
MsqError err 
)

Definition at line 412 of file MeshImplData.cpp.

References deletedElementList, elementList, MSQ_ERRZERO, and set_element().

{
    size_t index;
    if( !deletedElementList.empty() )
    {
        index = deletedElementList[deletedElementList.size() - 1];
        deletedElementList.pop_back();
    }
    else
    {
        index = elementList.size();
        elementList.resize( elementList.size() + 1 );
    }

    set_element( index, vertices, topology, err );
    MSQ_ERRZERO( err );
    return index;
}
size_t MBMesquite::MeshImplData::add_vertex ( const Vector3D coords,
bool  fixed,
MsqError err 
)

Add a new vertex

Definition at line 373 of file MeshImplData.cpp.

References deletedVertexList, MSQ_ERRZERO, reset_vertex(), and vertexList.

{
    size_t index;

    if( !deletedVertexList.empty() )
    {
        index = deletedVertexList[deletedVertexList.size() - 1];
        deletedVertexList.pop_back();
        reset_vertex( index, coords, fixed, err );
        MSQ_ERRZERO( err );
    }
    else
    {
        index = vertexList.size();
        vertexList.push_back( Vertex( coords, fixed ) );
    }

    return index;
}
void MBMesquite::MeshImplData::all_elements ( std::vector< size_t > &  list,
MsqError err 
) const

Get all elements

Definition at line 605 of file MeshImplData.cpp.

References elementList.

Referenced by MBMesquite::MeshImpl::get_all_elements(), and MBMesquite::MeshImpl::vtk_store_cell_data().

{
    list.clear();
    for( size_t idx = 0; idx < elementList.size(); ++idx )
        if( !elementList[idx].connectivity.empty() ) list.push_back( idx );
}
void MBMesquite::MeshImplData::all_vertices ( std::vector< size_t > &  list,
MsqError err 
) const

Get all vertices, including mid-nodes

Definition at line 598 of file MeshImplData.cpp.

References vertexList.

Referenced by MBMesquite::MeshImpl::get_all_vertices(), and MBMesquite::MeshImpl::vtk_store_point_data().

{
    list.clear();
    for( size_t idx = 0; idx < vertexList.size(); ++idx )
        if( vertexList[idx].valid ) list.push_back( idx );
}

Clear all data

Definition at line 213 of file MeshImplData.cpp.

References deletedElementList, deletedVertexList, elementList, haveSlavedFlags, and vertexList.

Referenced by MBMesquite::MeshImpl::clear().

{
    vertexList.clear();
    elementList.clear();
    deletedVertexList.clear();
    deletedElementList.clear();
    haveSlavedFlags = false;
}
void MBMesquite::MeshImplData::clear_element ( size_t  index,
MsqError err 
) [private]

Clear existing element data

Definition at line 294 of file MeshImplData.cpp.

References MBMesquite::adj(), conn, corners, elementList, MBMesquite::MsqError::INVALID_ARG, MSQ_SETERR, and vertexList.

Referenced by delete_element(), and reset_element().

{
    if( index >= elementList.size() )
    {
        MSQ_SETERR( err )( "Invalid element handle", MsqError::INVALID_ARG );
        return;
    }

    unsigned numvert = TopologyInfo::corners( elementList[index].topology );
    if( numvert )
        for( unsigned i = numvert; i < elementList[index].connectivity.size(); ++i )
            --vertexList[elementList[index].connectivity[i]].midcount;

    std::vector< size_t >& conn = elementList[index].connectivity;
    for( std::vector< size_t >::iterator iter = conn.begin(); iter != conn.end(); ++iter )
    {
        std::vector< size_t >& adj = vertexList[*iter].adjacencies;
        for( std::vector< size_t >::iterator iter2 = adj.begin(); iter2 != adj.end(); ++iter2 )
        {
            if( *iter2 == index )
            {
                adj.erase( iter2 );
                break;
            }
        }
    }
    conn.clear();
}
void MBMesquite::MeshImplData::copy_higher_order ( std::vector< size_t > &  mid_nodes,
std::vector< size_t > &  vertices,
std::vector< size_t > &  vertex_indices,
std::vector< size_t > &  index_offsets,
MsqError err 
)

Get all mid-nodes and their adjacent corner vertices

Definition at line 506 of file MeshImplData.cpp.

References MBMesquite::MeshImplData::Vertex::adjacencies, MBMesquite::MeshImplData::Element::connectivity, elementList, INTERNAL_ERROR, MBMesquite::MsqError::INVALID_STATE, is_vertex_valid(), MBMesquite::MeshImplData::Vertex::midcount, MSQ_ERRRTN, MSQ_SETERR, moab::side_number(), MBMesquite::MeshImplData::Element::topology, MBMesquite::MeshImplData::Vertex::valid, and vertexList.

{
    mid_nodes.clear();
    vertices.clear();
    vertex_indices.clear();
    index_offsets.clear();

    // Create a map of from vertex handle to index in "vertices"
    // Use vertexList.size() to mean uninitialized.
    size_t v;
    std::vector< size_t > vert_map( vertexList.size() );
    for( v = 0; v < vertexList.size(); ++v )
        vert_map[v] = vertexList.size();

    // Loop over all mid-side vertices
    for( v = 0; v < vertexList.size(); ++v )
    {
        const Vertex& vert = vertexList[v];

        // Not a mid-side vertex, skip it
        if( !vert.valid || !vert.midcount ) continue;

        // Populate "verts" with the handles of all adjacent corner vertices
        assert( vert.adjacencies.size() );  // shouldn't be able to fail if vert.midcount > 0
        int elem_indx = vert.adjacencies[0];
        Element& elem = elementList[elem_indx];

        // Find index of node in elem's connectivity list
        unsigned index;
        for( index = 0; index < elem.connectivity.size(); ++index )
            if( elem.connectivity[index] == v ) break;
        if( index == elem.connectivity.size() )
        {
            MSQ_SETERR( err )( "Inconsistent data.", MsqError::INTERNAL_ERROR );
            return;
        }

        // Given the index in the element's connectivity list,
        // get the side of the element containing the mid-node.
        unsigned side_dim, side_num;
        TopologyInfo::side_number( elem.topology, elem.connectivity.size(), index, side_dim, side_num, err );MSQ_ERRRTN( err );

        if( !side_dim )  // Not a mid-side node
        {
            MSQ_SETERR( err )( MsqError::INVALID_STATE, "Improperly connected mesh." );
            return;
        }

        // Get the adjacent corner vertices from the element side.
        unsigned num_corners;
        const unsigned* corner_indices =
            TopologyInfo::side_vertices( elem.topology, side_dim, side_num, num_corners, err );MSQ_ERRRTN( err );

        // Add the mid-side node to the output list
        mid_nodes.push_back( v );
        // Store offset at which the indices of the corner
        // vertices adjacent to this mid-side node will be
        // stored in "vertex_indices".
        index_offsets.push_back( vertex_indices.size() );
        // For each adjacent corner vertex, if the vertex is not
        // already in "vertices" add it, and add the index to
        // the adjacency list for this mid-side node.
        for( unsigned i = 0; i < num_corners; ++i )
        {
            size_t vert_idx = elem.connectivity[corner_indices[i]];
            assert( is_vertex_valid( vert_idx ) );

            if( vert_map[vert_idx] == vertexList.size() )
            {
                vert_map[vert_idx] = vertices.size();
                vertices.push_back( vert_idx );
            }
            vertex_indices.push_back( vert_map[vert_idx] );
        }
    }
    index_offsets.push_back( vertex_indices.size() );
}
void MBMesquite::MeshImplData::copy_mesh ( size_t *  vertex_handle_array,
size_t *  element_hanlde_array,
size_t *  element_conn_offsets,
size_t *  element_conn_indices 
)

Copy internal representation into CSR rep Does not include mid-nodes.

Definition at line 449 of file MeshImplData.cpp.

References conn, MBMesquite::MeshImplData::Element::connectivity, corners, elementList, MBMesquite::MeshImplData::Element::topology, and vertexList.

{
    std::vector< size_t > vertex_map( vertexList.size() );
    size_t vh_index = 0;
    for( size_t v = 0; v < vertexList.size(); ++v )
    {
        if( vertexList[v].valid
#ifdef SEPARATE_MID_NODES
            && vertexList[v].midcount < vertexList[v].adjacencies.size()
#endif
        )
        {
            vertex_handle_array[vh_index] = v;
            vertex_map[v]                 = vh_index;
            ++vh_index;
        }
        else
        {
            vertex_map[v] = vertexList.size();
        }
    }

    size_t offset = 0;
    for( size_t e = 0; e < elementList.size(); ++e )
    {
        Element& elem = elementList[e];
        size_t cl;
#ifdef SEPARATE_MID_NODES
        cl = TopologyInfo::corners( elem.topology );
        if( !cl )
#endif
            cl = elem.connectivity.size();
        if( cl )
        {
            *element_handle_array = e;
            ++element_handle_array;

            *element_conn_offsets = offset;
            ++element_conn_offsets;
            offset += cl;

            std::vector< size_t >::iterator conn = elem.connectivity.begin();
            std::vector< size_t >::iterator end  = conn + cl;
            while( conn != end )
            {
                *element_conn_indices = vertex_map[*conn];
                ++element_conn_indices;
                ++conn;
            }
        }
    }
    *element_conn_offsets = offset;
}
void MBMesquite::MeshImplData::delete_element ( size_t  index,
MsqError err 
)

Delete an element

Definition at line 443 of file MeshImplData.cpp.

References clear_element(), deletedElementList, and MSQ_ERRRTN.

{
    clear_element( index, err );MSQ_ERRRTN( err );
    deletedElementList.push_back( index );
}
void MBMesquite::MeshImplData::delete_vertex ( size_t  index,
MsqError err 
)

Delete a vertex - may not be referenced by any element

Definition at line 431 of file MeshImplData.cpp.

References deletedVertexList, MBMesquite::MsqError::INVALID_ARG, is_vertex_valid(), MSQ_SETERR, and vertexList.

{
    if( !is_vertex_valid( index ) )
    {
        MSQ_SETERR( err )( "Invalid vertex handle", MsqError::INVALID_ARG );
        return;
    }

    vertexList[index].valid = false;
    deletedVertexList.push_back( index );
}
void MBMesquite::MeshImplData::element_topology ( size_t  index,
EntityTopology  type,
MsqError err 
)

Set element type

Definition at line 168 of file MeshImplData.cpp.

References corners, elementList, MBMesquite::MsqError::INVALID_ARG, is_element_valid(), MSQ_SETERR, and vertexList.

{
    if( !is_element_valid( index ) )
    {
        MSQ_SETERR( err )( "Invalid element handle", MsqError::INVALID_ARG );
        return;
    }

    unsigned i, numvert;

    numvert = TopologyInfo::corners( elementList[index].topology );
    if( numvert )
        for( i = numvert; i < elementList[index].connectivity.size(); ++i )
            --vertexList[elementList[index].connectivity[i]].midcount;

    elementList[index].topology = type;

    numvert = TopologyInfo::corners( elementList[index].topology );
    if( numvert )
        for( i = numvert; i < elementList[index].connectivity.size(); ++i )
            ++vertexList[elementList[index].connectivity[i]].midcount;
}
void MBMesquite::MeshImplData::get_adjacent_elements ( std::vector< size_t >::const_iterator  nodes,
std::vector< size_t >::const_iterator  nodes_end,
std::vector< size_t > &  elems_out,
MsqError err 
)

Get elements adjacent to ALL of the passed nodes.

Return the list of elements that is the intersection of the adjacency lists of the specified vertices.

Definition at line 612 of file MeshImplData.cpp.

References MBMesquite::MsqError::INVALID_ARG, is_vertex_valid(), MSQ_SETERR, and vertexList.

Referenced by has_adjacent_elements().

{
    if( node_iter == node_end || !is_vertex_valid( *node_iter ) )
    {
        MSQ_SETERR( err )( MsqError::INVALID_ARG );
        return;
    }

    // Get list of elements adjacent to first node
    elems = vertexList[*node_iter].adjacencies;

    // For each aditional node, intersect elems with elements adjacent to node
    for( ++node_iter; node_iter != node_end; ++node_iter )
    {
        std::vector< size_t >::iterator elem_iter = elems.begin();
        while( elem_iter != elems.end() )
        {
            std::vector< size_t >::const_iterator adj_iter      = vertexList[*node_iter].adjacencies.begin();
            const std::vector< size_t >::const_iterator adj_end = vertexList[*node_iter].adjacencies.end();
            for( ; adj_iter != adj_end; ++adj_iter )
                if( *elem_iter == *adj_iter ) break;

            if( adj_iter == adj_end )
            {
                *elem_iter = elems[elems.size() - 1];
                elems.pop_back();
            }
            else
            {
                ++elem_iter;
            }
        }
    }
}
unsigned char MBMesquite::MeshImplData::get_vertex_byte ( size_t  index,
MsqError err 
) const

Get vertex byte

Definition at line 135 of file MeshImplData.cpp.

References MBMesquite::MsqError::INVALID_ARG, is_vertex_valid(), MSQ_SETERR, and vertexList.

Referenced by MBMesquite::MeshImpl::vertices_get_byte().

{
    if( !is_vertex_valid( index ) )
    {
        MSQ_SETERR( err )( "Invalid vertex handle", MsqError::INVALID_ARG );
        return 0;
    }

    return vertexList[index].byte;
}
const Vector3D & MBMesquite::MeshImplData::get_vertex_coords ( size_t  index,
MsqError err 
) const

Get vertex coordinates

Definition at line 74 of file MeshImplData.cpp.

References MBMesquite::dummy_vtx, MBMesquite::MsqError::INVALID_ARG, is_vertex_valid(), MSQ_SETERR, and vertexList.

Referenced by MBMesquite::MeshImpl::vertices_get_coordinates(), MBMesquite::MeshImpl::write_exodus(), and MBMesquite::MeshImpl::write_vtk().

{
    if( !is_vertex_valid( index ) )
    {
        MSQ_SETERR( err )( "Invalid vertex handle", MsqError::INVALID_ARG );
        return dummy_vtx;
    }

    return vertexList[index].coords;
}
bool MBMesquite::MeshImplData::has_adjacent_elements ( size_t  elem,
const std::vector< size_t > &  nodes,
MsqError err 
) [private]

helper function for skinning

Check if any elements adjacent to a side of an element are of the same dimension as the input element.

Parameters:
elemThe element
nodesThe nodes composing the side of the element

Definition at line 650 of file MeshImplData.cpp.

References dim, elementList, and get_adjacent_elements().

Referenced by skin().

{
    std::vector< size_t > adj_elems;
    const unsigned dim = TopologyInfo::dimension( elementList[elem].topology );
    get_adjacent_elements( nodes.begin(), nodes.end(), adj_elems, err );

    std::vector< size_t >::iterator iter;
    for( iter = adj_elems.begin(); iter != adj_elems.end(); ++iter )
        if( *iter != elem && TopologyInfo::dimension( elementList[*iter].topology ) == dim ) break;

    return iter != adj_elems.end();
}

Definition at line 188 of file MeshImplData.hpp.

References haveSlavedFlags.

Referenced by vertex_is_slaved(), and MBMesquite::MeshImpl::write_vtk().

    {
        return haveSlavedFlags;
    }
bool MBMesquite::MeshImplData::is_corner_node ( size_t  index) const

Check if the specified node is used as a corner vertex on any element

Definition at line 593 of file MeshImplData.cpp.

References is_vertex_valid(), and vertexList.

Referenced by MBMesquite::MeshImplVertIter::operator++().

{
    return is_vertex_valid( index ) && vertexList[index].midcount < vertexList[index].adjacencies.size();
}
bool MBMesquite::MeshImplData::is_mid_node ( size_t  index) const

Check if the specified node is used as a mid-node on any element

Definition at line 588 of file MeshImplData.cpp.

References is_vertex_valid(), and vertexList.

{
    return is_vertex_valid( index ) && vertexList[index].midcount > 0;
}

Get number of vertex uses (sum of connectivity length for all elements) Does not count mid-nodes

Definition at line 59 of file MeshImplData.cpp.

References corners, and elementList.

Referenced by MBMesquite::MeshImpl::write_vtk().

{
    size_t result = 0;
    for( std::vector< Element >::const_iterator iter = elementList.begin(); iter != elementList.end(); ++iter )
    {
#ifdef SEPARATE_MID_NODES
        unsigned from_topo = TopologyInfo::corners( iter->topology );
        result += from_topo ? from_topo : iter->connectivity.size();
#else
        result += iter->connectivity.size();
#endif
    }
    return result;
}

Get number of vertices, does not include mid-nodes

Definition at line 41 of file MeshImplData.cpp.

References vertexList.

Referenced by MBMesquite::MeshImpl::vtk_read_dataset(), MBMesquite::MeshImpl::vtk_read_point_data(), MBMesquite::MeshImpl::write_exodus(), and MBMesquite::MeshImpl::write_vtk().

{
    size_t count = 0;
    for( std::vector< Vertex >::const_iterator iter = vertexList.begin(); iter != vertexList.end(); ++iter )
#ifdef SEPARATE_MID_NODES
        if( iter->valid && iter->midcount < iter->adjacencies.size() )
#else
        if( iter->valid )
#endif
            ++count;
    return count;
}
void MBMesquite::MeshImplData::reset_element ( size_t  index,
const std::vector< long > &  vertices,
EntityTopology  topology,
MsqError err 
)

Clear element at specified index (if any) including connectivity and adjacency data, and re-initialize with passed data.

Definition at line 276 of file MeshImplData.cpp.

References clear_element(), MSQ_ERRRTN, and set_element().

Referenced by MBMesquite::MeshImpl::MeshImpl(), MBMesquite::MeshImpl::read_exodus(), MBMesquite::MeshImpl::vtk_create_structured_elems(), MBMesquite::MeshImpl::vtk_read_polygons(), and MBMesquite::MeshImpl::vtk_read_unstructured_grid().

{
    clear_element( index, err );MSQ_ERRRTN( err );
    set_element( index, vertices, topology, err );MSQ_ERRRTN( err );
}
void MBMesquite::MeshImplData::reset_element ( size_t  index,
const std::vector< size_t > &  vertices,
EntityTopology  topology,
MsqError err 
)

Definition at line 285 of file MeshImplData.cpp.

References clear_element(), MSQ_ERRRTN, and set_element().

{
    clear_element( index, err );MSQ_ERRRTN( err );
    set_element( index, vertices, topology, err );MSQ_ERRRTN( err );
}
void MBMesquite::MeshImplData::set_element ( size_t  index,
const std::vector< long > &  vertices,
EntityTopology  topology,
MsqError err 
) [private]

Set cleared element

Definition at line 323 of file MeshImplData.cpp.

References conn.

Referenced by add_element(), and reset_element().

{
    if( sizeof( long ) == sizeof( size_t ) )
        set_element( index, *reinterpret_cast< const std::vector< size_t >* >( &vertices ), topology, err );
    else
    {
        std::vector< size_t > conn( vertices.size() );
        std::copy( vertices.begin(), vertices.end(), conn.begin() );
        set_element( index, conn, topology, err );
    }
}
void MBMesquite::MeshImplData::set_element ( size_t  index,
const std::vector< size_t > &  vertices,
EntityTopology  topology,
MsqError err 
) [private]

Set cleared element

Definition at line 338 of file MeshImplData.cpp.

References MBMesquite::adj(), corners, elementList, MBMesquite::MsqError::INVALID_ARG, is_vertex_valid(), MSQ_SETERR, and vertexList.

{
    if( index >= elementList.size() )
    {
        MSQ_SETERR( err )( "Invalid element handle", MsqError::INVALID_ARG );
        return;
    }

    elementList[index].connectivity = vertices;
    elementList[index].topology     = topology;

    for( std::vector< size_t >::const_iterator iter = vertices.begin(); iter != vertices.end(); ++iter )
    {
        if( !is_vertex_valid( *iter ) )
        {
            MSQ_SETERR( err )( "Invalid vertex handle", MsqError::INVALID_ARG );
            return;
        }

        std::vector< size_t >& adj = vertexList[*iter].adjacencies;
        for( std::vector< size_t >::iterator iter2 = adj.begin(); iter2 != adj.end(); ++iter2 )
            if( *iter2 == index ) return;

        adj.push_back( index );
    }

    unsigned numvert = TopologyInfo::corners( elementList[index].topology );
    if( numvert )
        for( unsigned i = numvert; i < elementList[index].connectivity.size(); ++i )
            ++vertexList[elementList[index].connectivity[i]].midcount;
}
void MBMesquite::MeshImplData::set_vertex_byte ( size_t  index,
unsigned char  value,
MsqError err 
)

Set vertex byte

Definition at line 146 of file MeshImplData.cpp.

References MBMesquite::MsqError::INVALID_ARG, is_vertex_valid(), MSQ_SETERR, value(), and vertexList.

Referenced by MBMesquite::MeshImpl::vertices_set_byte().

{
    if( !is_vertex_valid( index ) )
    {
        MSQ_SETERR( err )( "Invalid vertex handle", MsqError::INVALID_ARG );
        return;
    }

    vertexList[index].byte = value;
}
void MBMesquite::MeshImplData::set_vertex_coords ( size_t  index,
const Vector3D coords,
MsqError err 
)

Set vertex coordinates

Definition at line 244 of file MeshImplData.cpp.

References MBMesquite::MsqError::INVALID_ARG, is_vertex_valid(), MSQ_SETERR, and vertexList.

Referenced by MBMesquite::MeshImpl::vertex_set_coordinates().

{
    if( !is_vertex_valid( index ) )
    {
        MSQ_SETERR( err )( "Invalid vertex handle", MsqError::INVALID_ARG );
        return;
    }

    vertexList[index].coords = coords;
}
void MBMesquite::MeshImplData::skin ( std::vector< size_t > &  sides,
MsqError err 
)

Skin mesh.

Get the boundary of a mesh as element sides

Parameters:
sidesElement sides as pairs of values : { elem_index, side_number }

Definition at line 663 of file MeshImplData.cpp.

References MBMesquite::adj(), conn, dim, elementList, has_adjacent_elements(), is_element_valid(), MSQ_ERRRTN, MBMesquite::POLYGON, and MBMesquite::POLYHEDRON.

{
    std::vector< size_t > side_nodes;

    // For each element in mesh
    for( size_t elem = 0; elem < elementList.size(); ++elem )
    {
        if( !is_element_valid( elem ) ) continue;

        // For each side of the element, check if there
        // are any adjacent elements.
        const EntityTopology topo   = elementList[elem].topology;
        std::vector< size_t >& conn = elementList[elem].connectivity;
        switch( topo )
        {
                // For normal elements (not poly****)
            default: {
                unsigned num = TopologyInfo::sides( topo );
                unsigned dim = TopologyInfo::dimension( topo ) - 1;
                // For each side
                for( unsigned side = 0; side < num; ++side )
                {
                    // Get list of vertices defining the side
                    unsigned count;
                    const unsigned* indices = TopologyInfo::side_vertices( topo, dim, side, count, err );MSQ_ERRRTN( err );
                    side_nodes.clear();
                    for( unsigned k = 0; k < count; ++k )
                        side_nodes.push_back( conn[indices[k]] );

                    // If no adjacent element, add side to output list
                    bool adj = has_adjacent_elements( elem, side_nodes, err );MSQ_ERRRTN( err );
                    if( !adj )
                    {
                        sides.push_back( elem );
                        sides.push_back( side );
                    }
                }
            }
            break;

            case POLYGON: {
                for( unsigned side = 0, next = 1; next < conn.size(); ++side, ++next )
                {
                    side_nodes.clear();
                    side_nodes.push_back( conn[side] );
                    side_nodes.push_back( conn[next] );

                    // If no adjacent element, add side to output list
                    bool adj = has_adjacent_elements( elem, side_nodes, err );MSQ_ERRRTN( err );
                    if( !adj )
                    {
                        sides.push_back( elem );
                        sides.push_back( side );
                    }
                }
            }
            break;

            case POLYHEDRON: {
                for( unsigned side = 0; side < conn.size(); ++side )
                {
                    side_nodes = elementList[conn[side]].connectivity;

                    // If no adjacent element, add side to output list
                    bool adj = has_adjacent_elements( elem, side_nodes, err );MSQ_ERRRTN( err );
                    if( !adj )
                    {
                        sides.push_back( elem );
                        sides.push_back( side );
                    }
                }
            }
            break;
        }  // switch(topo)
    }      // for (elementList)
}
void MBMesquite::MeshImplData::slave_vertex ( size_t  index,
bool  flag,
MsqError err 
)

Set vertex slaved flag

Definition at line 123 of file MeshImplData.cpp.

References haveSlavedFlags, MBMesquite::MsqError::INVALID_ARG, is_vertex_valid(), MSQ_SETERR, and vertexList.

Referenced by MBMesquite::MeshImpl::read_vtk(), MBMesquite::MeshImpl::set_all_slaved_flags(), and MBMesquite::MeshImpl::set_skin_flags().

{
    if( !is_vertex_valid( index ) )
    {
        MSQ_SETERR( err )( "Invalid vertex handle", MsqError::INVALID_ARG );
        return;
    }

    vertexList[index].slaved = flag;
    haveSlavedFlags          = true;
}
const std::vector< size_t > & MBMesquite::MeshImplData::vertex_adjacencies ( size_t  index,
MsqError err 
) const

Get vertex adjacency list

Definition at line 202 of file MeshImplData.cpp.

References MBMesquite::dummy_list, MBMesquite::MsqError::INVALID_ARG, is_vertex_valid(), MSQ_SETERR, and vertexList.

Referenced by MBMesquite::is_side_boundary(), and MBMesquite::MeshImpl::vertices_get_attached_elements().

{
    if( !is_vertex_valid( index ) )
    {
        MSQ_SETERR( err )( "Invalid vertex handle", MsqError::INVALID_ARG );
        return dummy_list;
    }

    return vertexList[index].adjacencies;
}
bool MBMesquite::MeshImplData::vertex_is_fixed ( size_t  index,
MsqError err 
) const

Get vertex fixed flag

Definition at line 85 of file MeshImplData.cpp.

References MBMesquite::MsqError::INVALID_ARG, is_vertex_valid(), MSQ_SETERR, and vertexList.

Referenced by MBMesquite::MeshImpl::vertices_get_fixed_flag(), MBMesquite::MeshImpl::write_exodus(), and MBMesquite::MeshImpl::write_vtk().

{
    if( !is_vertex_valid( index ) )
    {
        MSQ_SETERR( err )( "Invalid vertex handle", MsqError::INVALID_ARG );
        return false;
    }

    return vertexList[index].fixed;
}
bool MBMesquite::MeshImplData::vertex_is_slaved ( size_t  index,
MsqError err 
) const

Get vertex slaved flag

Definition at line 96 of file MeshImplData.cpp.

References have_slaved_flags(), MBMesquite::MsqError::INVALID_ARG, MBMesquite::MsqError::INVALID_STATE, is_vertex_valid(), MSQ_SETERR, and vertexList.

Referenced by MBMesquite::MeshImpl::vertices_get_slaved_flag(), and MBMesquite::MeshImpl::write_vtk().

{
    if( !is_vertex_valid( index ) )
    {
        MSQ_SETERR( err )( "Invalid vertex handle", MsqError::INVALID_ARG );
        return false;
    }
    if( !have_slaved_flags() )
    {
        MSQ_SETERR( err )( "Slave flags not set", MsqError::INVALID_STATE );
        return false;
    }

    return vertexList[index].slaved;
}

Member Data Documentation

std::vector< size_t > MBMesquite::MeshImplData::deletedElementList [private]

List of unused indices in element list

Definition at line 245 of file MeshImplData.hpp.

Referenced by add_element(), clear(), delete_element(), and num_elements().

std::vector< size_t > MBMesquite::MeshImplData::deletedVertexList [private]

List of unused indices in vertex list

Definition at line 243 of file MeshImplData.hpp.

Referenced by add_vertex(), clear(), and delete_vertex().

Definition at line 247 of file MeshImplData.hpp.

Referenced by clear(), have_slaved_flags(), and slave_vertex().

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