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

Mesquite iMesh Adapter. More...

#include <MsqIMesh.hpp>

+ Inheritance diagram for MBMesquite::MsqIMesh:
+ Collaboration diagram for MBMesquite::MsqIMesh:

Public Member Functions

 MsqIMesh ()
virtual ~MsqIMesh ()
 MsqIMesh (iMesh_Instance imesh, iBase_EntitySetHandle meshset, iBase_EntityType element_dimension, MsqError &err, const iBase_TagHandle *fixed_tag=0, const iBase_TagHandle *slaved_tag=0)
 Create iMesh adaptor instance.
 MsqIMesh (iMesh_Instance imesh, iBase_EntityType element_dimension, MsqError &err, const iBase_TagHandle *fixed_tag=0, const iBase_TagHandle *slaved_tag=0)
 Create iMesh adaptor instance.
void set_active_set (iBase_EntitySetHandle meshset, iBase_EntityType element_dimension, MsqError &err)
 set mesh to be smoothed.
void set_fixed_tag (iBase_TagHandle tag, MsqError &err)
 Set tag for vertex fixed flag.
void set_slaved_tag (iBase_TagHandle tag, MsqError &err)
 Set tag for vertex slaved flag.
void clear_fixed_tag ()
 No tag for vertex fixed flag.
void clear_slaved_tag ()
 No tag for vertex fixed flag.
const iBase_TagHandleget_fixed_tag () const
 Get tag for vertex fixed flag.
const iBase_TagHandleget_slaved_tag () const
 Get tag for vertex slaved flag.
virtual iMesh_Instance get_imesh_instance () const
virtual iBase_EntitySetHandle get_entity_set () const
virtual int get_geometric_dimension (MBMesquite::MsqError &)
 Get dimension of vertex coordinates (2D vs. 3D).
virtual void get_all_elements (std::vector< ElementHandle > &elements, MsqError &err)
 Get handles for all elemnents.
virtual void get_all_vertices (std::vector< VertexHandle > &vertices, MsqError &err)
 Get handles for all vertices.
virtual void vertices_get_fixed_flag (const VertexHandle vert_array[], std::vector< bool > &fixed_flag_array, size_t num_vtx, MsqError &err)
 Query "fixed" flag for a vertex.
virtual void vertices_get_slaved_flag (const VertexHandle vert_array[], std::vector< bool > &slaved_flag_array, size_t num_vtx, MsqError &err)
virtual void vertices_get_coordinates (const VertexHandle vert_array[], MsqVertex *coordinates, size_t num_vtx, MsqError &err)
 Get vertex coordinates.
virtual void vertex_set_coordinates (VertexHandle vertex, const Vector3D &coordinates, MsqError &err)
 Set vertex coordinates.
virtual void vertex_set_byte (VertexHandle vertex, unsigned char byte, MsqError &err)
 Set vertex mark.
virtual void vertices_set_byte (const VertexHandle *vert_array, const unsigned char *byte_array, size_t array_size, MsqError &err)
 Set vertex mark.
virtual void vertex_get_byte (VertexHandle vertex, unsigned char *byte, MsqError &err)
 Get vertex mark.
virtual void vertices_get_byte (const VertexHandle *vert_array, unsigned char *byte_array, size_t array_size, MsqError &err)
 Get vertex mark.
virtual void vertices_get_attached_elements (const VertexHandle *vertex_array, size_t num_vertices, std::vector< ElementHandle > &elements, std::vector< size_t > &offsets, MsqError &err)
 Get vertex-to-element adjacencies.
virtual void elements_get_attached_vertices (const ElementHandle *elem_handles, size_t num_elems, std::vector< VertexHandle > &vertices, std::vector< size_t > &offsets, MsqError &err)
 Get element connectivity.
virtual void elements_get_topologies (const ElementHandle *element_handle_array, EntityTopology *element_topologies, size_t num_elements, MsqError &err)
 Return topology type enum for an array of elements.
virtual void release_entity_handles (const EntityHandle *handle_array, size_t num_handles, MsqError &err)
 no-op
virtual void release ()
virtual TagHandle tag_create (const std::string &tag_name, TagType type, unsigned length, const void *default_value, MsqError &err)
 Create a tag.
virtual void tag_delete (TagHandle handle, MsqError &err)
 Remove a tag and all corresponding data.
virtual TagHandle tag_get (const std::string &name, MsqError &err)
 Get handle for existing tag, by name.
virtual void tag_properties (TagHandle handle, std::string &name_out, TagType &type_out, unsigned &length_out, MsqError &err)
 Get properites of tag.
virtual void tag_set_element_data (TagHandle handle, size_t num_elems, const ElementHandle *elem_array, const void *tag_data, MsqError &err)
 Set tag values on elements.
virtual void tag_set_vertex_data (TagHandle handle, size_t num_elems, const VertexHandle *node_array, const void *tag_data, MsqError &err)
 Set tag values on vertices.
virtual void tag_get_element_data (TagHandle handle, size_t num_elems, const ElementHandle *elem_array, void *tag_data, MsqError &err)
 Get tag values on elements.
virtual void tag_get_vertex_data (TagHandle handle, size_t num_elems, const VertexHandle *node_array, void *tag_data, MsqError &err)
 Get tag values on vertices.

Protected Member Functions

iBase_TagValueType check_valid_flag_tag (iBase_TagHandle tag, const char *which_flag, MsqError &err)
void set_int_tag (void *tag, void *meshset, int value, MsqError &err)
void get_adjacent_entities (const iBase_EntityHandle *source, size_t num_source, iBase_EntityType target_type, std::vector< EntityHandle > &target, std::vector< size_t > &offsets, MsqError &err)
 Call TSTTM::Arr::getEntArrAdj.

Protected Attributes

iMesh_Instance meshInstance

Private Member Functions

void init_active_mesh (iMesh_Instance mesh, MsqError &err, const iBase_TagHandle *fixed_tag, const iBase_TagHandle *slaved_tag)
void get_flag_data (iBase_TagHandle tag, bool have_tag, iBase_TagValueType type, const VertexHandle vert_array[], std::vector< bool > &flag_array, size_t num_vtx, MsqError &err)
void tag_set_data (TagHandle handle, size_t num_elems, const EntityHandle *handle_array, const void *tag_data, MsqError &err)
 Set tag values.
void tag_get_data (TagHandle handle, size_t num_elems, const EntityHandle *handle_array, void *tag_data, MsqError &err)
 Get tag values.

Private Attributes

bool haveMesh
iBase_EntityType inputSetType
iBase_EntitySetHandle inputSet
iBase_TagHandle byteTag
bool createdByteTag
iBase_TagHandle fixedTag
bool haveFixedTag
iBase_TagValueType fixedTagType
iBase_TagHandle slavedTag
bool haveSlavedTag
iBase_TagValueType slavedTagType
int geometricDimension
EntityTopology topologyMap [iMesh_ALL_TOPOLOGIES+1]

Detailed Description

Mesquite iMesh Adapter.

Adpater for interfacing Mesquite with an application that provides the ITAPS iMesh interface for interacting with mesh data.

Definition at line 52 of file MsqIMesh.hpp.


Constructor & Destructor Documentation

Definition at line 89 of file MsqIMesh.cpp.

References byteTag, createdByteTag, ierr, iMesh_destroyTag, and meshInstance.

{
    int ierr;
    if( createdByteTag ) iMesh_destroyTag( meshInstance, byteTag, true, &ierr );
}
MBMesquite::MsqIMesh::MsqIMesh ( iMesh_Instance  imesh,
iBase_EntitySetHandle  meshset,
iBase_EntityType  element_dimension,
MsqError err,
const iBase_TagHandle fixed_tag = 0,
const iBase_TagHandle slaved_tag = 0 
)

Create iMesh adaptor instance.

Parameters:
imeshThe iMesh instance to interact with
meshsetThe set of elements for which to optimize the quality
element_dimensionOptimize the subset of the elements in 'meshset' with this dimension. Pass iBase_ALL_TYPES for both iBase_FACE and iBase_REGION elements. If 'meshset' is the root set, then this argument is typically either iBase_FACE or iBase_REGION.
fixed_tagA pointer to the tag handle designating a tag containing fixed flags for vertices. The tag must have size==1 and type==iBase_INTEGER or iBase_BYTES. A value of one for a vertex indicates that the vertex position is fixed. A value of zero indicates a free vertex (a vertex that Mesquite may move to improve mesh quality.) If this tag is not specified, then the boundary constraints of the optimization must be specified using an MsqIRel instance.
slaved_tagA pointer to the tag handle designating a tag containing slaved flags for vertices. The tag must have size==1 and type==iBase_INTEGER or iBase_BYTES. This tag value is ignored for corner vertices of elements. The concept of 'slaved' is applicable only to non-corner vertices in higher-order elements. A value of one for a vertex indicates that the vertex position should is a fucntion of the element shape function, while a zero value indicates that the element shape function is a function of the vertex position.

Definition at line 55 of file MsqIMesh.cpp.

References init_active_mesh(), MSQ_ERRRTN, and set_active_set().

    : meshInstance( mesh ), inputSetType( iBase_ALL_TYPES ), inputSet( 0 ), byteTag( 0 ), createdByteTag( false ),
      geometricDimension( 0 )
{
    init_active_mesh( mesh, err, fixed_tag, slaved_tag );MSQ_ERRRTN( err );
    set_active_set( meshset, type, err );MSQ_ERRRTN( err );
}
MBMesquite::MsqIMesh::MsqIMesh ( iMesh_Instance  imesh,
iBase_EntityType  element_dimension,
MsqError err,
const iBase_TagHandle fixed_tag = 0,
const iBase_TagHandle slaved_tag = 0 
)

Create iMesh adaptor instance.

This constructor is provided for the creation of an MsqIMesh instance that is to be re-used for multiple optimization calls for different sets of elements. set_active_set must be called to define the subset of the mesh to optimize before an instance constructed with this constructor may be used in an optimization.

Parameters:
imeshThe iMesh instance to interact with
element_dimensionOptimize the subset of the elements in root set with this dimension. Pass iBase_ALL_TYPES for both iBase_FACE and iBase_REGION elements. If 'meshset' is the root set, then this argument is typically either iBase_FACE or iBase_REGION.
fixed_tagA pointer to the tag handle designating a tag containing fixed flags for vertices. The tag must have size==1 and type==iBase_INTEGER or iBase_BYTES. A value of one for a vertex indicates that the vertex position is fixed. A value of zero indicates a free vertex (a vertex that Mesquite may move to improve mesh quality.) If this tag is not specified, then the boundary constraints of the optimization must be specified using an MsqIRel instance.
slaved_tagA pointer to the tag handle designating a tag containing slaved flags for vertices. The tag must have size==1 and type==iBase_INTEGER or iBase_BYTES. This tag value is ignored for corner vertices of elements. The concept of 'slaved' is applicable only to non-corner vertices in higher-order elements. A value of one for a vertex indicates that the vertex position should is a fucntion of the element shape function, while a zero value indicates that the element shape function is a function of the vertex position.

Definition at line 68 of file MsqIMesh.cpp.

References iBase_SUCCESS, ierr, iMesh_getRootSet, init_active_mesh(), MBMesquite::MsqError::INVALID_STATE, MSQ_ERRRTN, MSQ_SETERR, root_set, and set_active_set().

    : meshInstance( mesh ), inputSetType( iBase_ALL_TYPES ), inputSet( 0 ), byteTag( 0 ), createdByteTag( false ),
      geometricDimension( 0 )
{
    init_active_mesh( mesh, err, fixed_tag, slaved_tag );MSQ_ERRRTN( err );

    int ierr;
    iBase_EntitySetHandle root_set;
    iMesh_getRootSet( mesh, &root_set, &ierr );
    if( ierr != iBase_SUCCESS )
    {
        MSQ_SETERR( err )( "Invalid iMesh instance.", MsqError::INVALID_STATE );
        return;
    }
    set_active_set( root_set, type, err );MSQ_ERRRTN( err );
}

Member Function Documentation

iBase_TagValueType MBMesquite::MsqIMesh::check_valid_flag_tag ( iBase_TagHandle  tag,
const char *  which_flag,
MsqError err 
) [protected]

Definition at line 105 of file MsqIMesh.cpp.

References iBase_BYTES, iBase_ENTITY_HANDLE, iBase_INTEGER, iBase_SUCCESS, ierr, iMesh_getTagName, iMesh_getTagSizeBytes, iMesh_getTagType, MBMesquite::MsqError::INVALID_ARG, MBMesquite::MsqError::INVALID_STATE, meshInstance, MSQ_SETERR, and size.

Referenced by init_active_mesh(), set_fixed_tag(), and set_slaved_tag().

{
    int ierr, size, type;
    const int MAX_NAME_LEN = 127;
    char name[MAX_NAME_LEN + 1];

    std::fill( name, name + sizeof( name ), '\0' );
    iMesh_getTagName( meshInstance, tag, name, &ierr, MAX_NAME_LEN );
    name[MAX_NAME_LEN - 1] = '\0';  // make sure strings are null-terminated
    if( iBase_SUCCESS != ierr )
    {
        MSQ_SETERR( err )
        ( MsqError::INVALID_ARG, "Invalid tag handle for vertex %s flag", which_flag );
        return iBase_ENTITY_HANDLE;
    }
    iMesh_getTagSizeBytes( meshInstance, tag, &size, &ierr );
    if( iBase_SUCCESS != ierr || size != sizeof( int ) )
    {
        MSQ_SETERR( err )( MsqError::INVALID_STATE, "Tag \"%s\" exists with invalid size", name );
        return iBase_ENTITY_HANDLE;
    }

    iMesh_getTagType( meshInstance, tag, &type, &ierr );
    if( iBase_SUCCESS != ierr || ( type != iBase_INTEGER && type != iBase_BYTES ) )
    {
        MSQ_SETERR( err )( MsqError::INVALID_STATE, "Tag \"%s\" exists with invalid type", name );
        return iBase_ENTITY_HANDLE;
    }
    return static_cast< iBase_TagValueType >( type );
}

No tag for vertex fixed flag.

Definition at line 228 of file MsqIMesh.cpp.

References haveFixedTag.

{
    haveFixedTag = false;
}

No tag for vertex fixed flag.

Definition at line 246 of file MsqIMesh.cpp.

References haveSlavedTag.

{
    haveSlavedTag = false;
}
void MBMesquite::MsqIMesh::elements_get_attached_vertices ( const ElementHandle elements,
size_t  num_elems,
std::vector< VertexHandle > &  vertices,
std::vector< size_t > &  offsets,
MBMesquite::MsqError err 
) [virtual]

Get element connectivity.

Get connectivity

Parameters:
elements- Array of length num_elems containing elements handles of elements for which connectivity is to be queried.
vertices- Array of vertex handles in connectivity list.
offsets- Indices into vertex_handles, one per element

Implements MBMesquite::Mesh.

Definition at line 618 of file MsqIMesh.cpp.

References get_adjacent_entities(), iBase_VERTEX, and MSQ_CHKERR.

Referenced by get_all_vertices().

{
    assert( sizeof( iBase_EntityHandle ) == sizeof( EntityHandle ) );
    const iBase_EntityHandle* elems = reinterpret_cast< const iBase_EntityHandle* >( elements );
    get_adjacent_entities( elems, num_elems, iBase_VERTEX, vertices, offsets, err );MSQ_CHKERR( err );
}
void MBMesquite::MsqIMesh::elements_get_topologies ( const ElementHandle element_handle_array,
EntityTopology element_topologies,
size_t  num_elements,
MsqError err 
) [virtual]

Return topology type enum for an array of elements.

Implements MBMesquite::Mesh.

Definition at line 721 of file MsqIMesh.cpp.

References MBMesquite::arrptr(), iBase_SUCCESS, ierr, iMesh_getEntArrTopo, INTERNAL_ERROR, meshInstance, MSQ_SETERR, MBMesquite::process_itaps_error(), and topologyMap.

{
    if( !num_elements ) return;

    // don't copy unless we have to
    std::vector< int > topo_store;
    int* topo_array;
    if( sizeof( EntityTopology ) == sizeof( int ) )
        topo_array = (int*)element_topologies;
    else
    {
        topo_store.resize( num_elements );
        topo_array = arrptr( topo_store );
    }

    int ierr, junk1 = num_elements, junk2;
    assert( sizeof( ElementHandle ) == sizeof( iBase_EntityHandle ) );
    const iBase_EntityHandle* arr = reinterpret_cast< const iBase_EntityHandle* >( element_handle_array );
    iMesh_getEntArrTopo( meshInstance, arr, num_elements, &topo_array, &junk1, &junk2, &ierr );
    if( iBase_SUCCESS != ierr )
    {
        MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
        return;
    }

    for( size_t i = 0; i < num_elements; ++i )
        element_topologies[i] = topologyMap[topo_array[i]];
}
void MBMesquite::MsqIMesh::get_adjacent_entities ( const iBase_EntityHandle source,
size_t  num_source,
iBase_EntityType  target_type,
std::vector< EntityHandle > &  target,
std::vector< size_t > &  offsets,
MsqError err 
) [protected]

Call TSTTM::Arr::getEntArrAdj.

Common code for vertices_get_attached_elements and elements_get_attached_vertices

Parameters:
sourceArray of handles of source entities to query from
num_sourceThe length of source
target_typeThe type of entity to query for
targetThe output list of adjacent entities
offsetsFor each entity in source, the offset in target at which the corresponding adjacent entities are stored. (output)

Definition at line 470 of file MsqIMesh.cpp.

References MBMesquite::arrptr(), iBase_SUCCESS, ierr, iMesh_getEntArrAdj, INTERNAL_ERROR, meshInstance, MSQ_SETERR, and MBMesquite::process_itaps_error().

Referenced by elements_get_attached_vertices(), and vertices_get_attached_elements().

{
    if( num_source == 0 )
    {
        target.clear();
        offsets.clear();
        offsets.reserve( 1 );
        offsets.push_back( 0 );
        return;
    }

    int ierr, num_adj = 0, num_offset;

    assert( sizeof( size_t ) >= sizeof( int ) );
    offsets.resize( num_source + 1 );
    int* ptr2;
    bool expand = false;
    if( sizeof( size_t ) > sizeof( int ) )
    {
        ptr2   = (int*)malloc( sizeof( int ) * ( num_source + 1 ) );
        expand = true;
    }
    else
    {
        // sizeof(int) == sizeof(size_t)
        ptr2 = (int*)arrptr( offsets );
    }

    assert( sizeof( iBase_EntityHandle ) == sizeof( EntityHandle ) );
    bool have_adj = false;
    // If passed vector has allocated storage, try to use existing space
    if( target.capacity() >= num_source )
    {
        target.resize( target.capacity() );
        int junk1 = target.capacity(), junk3 = offsets.size();
        iBase_EntityHandle* ptr = reinterpret_cast< iBase_EntityHandle* >( arrptr( target ) );
        iMesh_getEntArrAdj( meshInstance, source, num_source, target_type, &ptr, &junk1, &num_adj, &ptr2, &junk3,
                            &num_offset, &ierr );
        if( iBase_SUCCESS == ierr )
        {
            have_adj = true;
            target.resize( num_adj );
        }
    }

    // If implementation passed back a size, try that
    if( !have_adj && num_adj && (unsigned)num_adj > target.capacity() )
    {
        target.resize( num_adj );
        int junk1 = target.capacity(), junk3 = offsets.size();
        iBase_EntityHandle* ptr = reinterpret_cast< iBase_EntityHandle* >( arrptr( target ) );
        iMesh_getEntArrAdj( meshInstance, source, num_source, target_type, &ptr, &junk1, &num_adj, &ptr2, &junk3,
                            &num_offset, &ierr );
        if( iBase_SUCCESS == ierr ) have_adj = true;
    }

    // Try with empty sidl array, and copy into elements vector
    if( !have_adj )
    {
        iBase_EntityHandle* mArray = 0;
        int junk1 = 0, junk3 = offsets.size();
        iMesh_getEntArrAdj( meshInstance, source, num_source, target_type, &mArray, &junk1, &num_adj, &ptr2, &junk3,
                            &num_offset, &ierr );
        if( iBase_SUCCESS != ierr )
        {
            MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
            return;
        }

        target.resize( num_adj );
        std::copy( mArray, mArray + num_adj, reinterpret_cast< iBase_EntityHandle* >( arrptr( target ) ) );
        free( mArray );
    }

    if( expand )
    {
        for( size_t i = num_offset; i > 0; --i )
            offsets[i - 1] = static_cast< size_t >( ptr2[i - 1] );
        free( ptr2 );
    }

    // iMesh implementations seem to be inconsistent with regard to
    // placing the last value on this list.
    if( offsets.size() - num_offset == 1 ) offsets[num_offset++] = num_adj;
    assert( (unsigned)num_offset == offsets.size() );
}
void MBMesquite::MsqIMesh::get_all_elements ( std::vector< ElementHandle > &  elements,
MsqError err 
) [virtual]

Get handles for all elemnents.

Implements MBMesquite::Mesh.

Definition at line 629 of file MsqIMesh.cpp.

References MBMesquite::arrptr(), iBase_ALL_TYPES, iBase_FACE, iBase_REGION, iBase_SUCCESS, ierr, iMesh_ALL_TOPOLOGIES, iMesh_getEntities, iMesh_getNumOfType, inputSet, inputSetType, INTERNAL_ERROR, meshInstance, MSQ_SETERR, and MBMesquite::process_itaps_error().

Referenced by get_all_vertices().

{
    int ierr, count_in, count_out;

    if( inputSetType == iBase_ALL_TYPES )
    {
        int num_vol, num_face;

        iMesh_getNumOfType( meshInstance, inputSet, iBase_FACE, &num_face, &ierr );
        if( iBase_SUCCESS != ierr )
        {
            MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
            return;
        }
        iMesh_getNumOfType( meshInstance, inputSet, iBase_REGION, &num_vol, &ierr );
        if( iBase_SUCCESS != ierr )
        {
            MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
            return;
        }
        elements.resize( num_face + num_vol );
        if( elements.empty() ) return;

        iBase_EntityHandle* ptr = reinterpret_cast< iBase_EntityHandle* >( arrptr( elements ) );
        if( num_face )
        {
            count_in = num_face + num_vol;
            iMesh_getEntities( meshInstance, inputSet, iBase_FACE, iMesh_ALL_TOPOLOGIES, &ptr, &count_in, &count_out,
                               &ierr );
            if( iBase_SUCCESS != ierr )
            {
                MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
                return;
            }
            assert( count_out == num_face );
        }

        if( num_vol )
        {
            ptr += num_face;
            count_in = num_vol;
            iMesh_getEntities( meshInstance, inputSet, iBase_REGION, iMesh_ALL_TOPOLOGIES, &ptr, &count_in, &count_out,
                               &ierr );
            if( iBase_SUCCESS != ierr )
            {
                MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
                return;
            }
            assert( count_out == num_vol );
        }
    }
    else
    {
        int count;
        iMesh_getNumOfType( meshInstance, inputSet, inputSetType, &count, &ierr );
        if( iBase_SUCCESS != ierr )
        {
            MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
            return;
        }

        if( !count ) return;
        elements.resize( count );

        iBase_EntityHandle* ptr = reinterpret_cast< iBase_EntityHandle* >( arrptr( elements ) );
        count_in                = count;
        iMesh_getEntities( meshInstance, inputSet, inputSetType, iMesh_ALL_TOPOLOGIES, &ptr, &count_in, &count_out,
                           &ierr );
        if( iBase_SUCCESS != ierr )
        {
            MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
            return;
        }
        assert( count_out == count );
    }
}
void MBMesquite::MsqIMesh::get_all_vertices ( std::vector< VertexHandle > &  vertices,
MsqError err 
) [virtual]

Get handles for all vertices.

Implements MBMesquite::Mesh.

Definition at line 706 of file MsqIMesh.cpp.

References MBMesquite::arrptr(), elements_get_attached_vertices(), get_all_elements(), and MSQ_CHKERR.

Referenced by set_active_set().

{
    std::vector< ElementHandle > elems;
    get_all_elements( elems, err );MSQ_CHKERR( err );
    if( elems.empty() ) return;

    std::vector< size_t > offsets;
    elements_get_attached_vertices( arrptr( elems ), elems.size(), vertices, offsets, err );MSQ_CHKERR( err );

    std::sort( vertices.begin(), vertices.end() );
    vertices.erase( std::unique( vertices.begin(), vertices.end() ), vertices.end() );
}

Definition at line 100 of file MsqIMesh.cpp.

References inputSet.

{
    return inputSet;
}

Get tag for vertex fixed flag.

Definition at line 233 of file MsqIMesh.cpp.

References fixedTag, and haveFixedTag.

{
    return haveFixedTag ? &fixedTag : 0;
}
void MBMesquite::MsqIMesh::get_flag_data ( iBase_TagHandle  tag,
bool  have_tag,
iBase_TagValueType  type,
const VertexHandle  vert_array[],
std::vector< bool > &  flag_array,
size_t  num_vtx,
MsqError err 
) [private]

Definition at line 279 of file MsqIMesh.cpp.

References MBMesquite::arrptr(), iBase_BYTES, iBase_INTEGER, iBase_SUCCESS, ierr, iMesh_getArrData, iMesh_getIntArrData, INTERNAL_ERROR, MBMesquite::MsqError::INVALID_STATE, meshInstance, MSQ_SETERR, MBMesquite::process_itaps_error(), and size.

Referenced by vertices_get_fixed_flag(), and vertices_get_slaved_flag().

{
    if( !num_vtx ) return;

    if( !have_tag )
    {
        flag_array.clear();
        flag_array.resize( num_vtx, false );
        return;
    }

    flag_array.resize( num_vtx );

    assert( sizeof( VertexHandle ) == sizeof( iBase_EntityHandle ) );
    const iBase_EntityHandle* arr = reinterpret_cast< const iBase_EntityHandle* >( vert_array );

    int ierr, alloc = num_vtx, size = 0;
    assert( (size_t)alloc == num_vtx );  // size_t can hold larger values than int if 64-bit

    if( type == iBase_INTEGER )
    {
        std::vector< int > values( num_vtx );
        int* ptr = arrptr( values );
        iMesh_getIntArrData( meshInstance, arr, num_vtx, tag, &ptr, &alloc, &size, &ierr );
        for( int i = 0; i < size; ++i )
            flag_array[i] = !!values[i];
    }
    else if( type == iBase_BYTES )
    {
        std::vector< char > values( num_vtx );
        void* ptr = arrptr( values );
        iMesh_getArrData( meshInstance, arr, num_vtx, tag, &ptr, &alloc, &size, &ierr );
        for( int i = 0; i < size; ++i )
            flag_array[i] = !!values[i];
    }
    else
    {
        MSQ_SETERR( err )( "Invalid tag type for vertex flag data", MsqError::INVALID_STATE );
        return;
    }

    // check if query for tag data failed
    if( iBase_SUCCESS != ierr )
    {
        MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
        return;
    }

    // make sure we got back the requested number of values
    assert( static_cast< size_t >( size ) == num_vtx );
}

Get dimension of vertex coordinates (2D vs. 3D).

Implements MBMesquite::Mesh.

Definition at line 272 of file MsqIMesh.cpp.

References geometricDimension.

{
    return geometricDimension;
}

Definition at line 95 of file MsqIMesh.cpp.

References meshInstance.

{
    return meshInstance;
}

Get tag for vertex slaved flag.

Definition at line 251 of file MsqIMesh.cpp.

References haveSlavedTag, and slavedTag.

{
    return haveSlavedTag ? &slavedTag : 0;
}
void MBMesquite::MsqIMesh::init_active_mesh ( iMesh_Instance  mesh,
MsqError err,
const iBase_TagHandle fixed_tag,
const iBase_TagHandle slaved_tag 
) [private]

Definition at line 136 of file MsqIMesh.cpp.

References byteTag, check_valid_flag_tag(), createdByteTag, fixedTag, fixedTagType, geometricDimension, haveFixedTag, haveSlavedTag, MBMesquite::HEXAHEDRON, iBase_INTEGER, iBase_SUCCESS, ierr, iMesh_ALL_TOPOLOGIES, iMesh_createTag, iMesh_getGeometricDimension, iMesh_getTagHandle, iMesh_getTagSizeBytes, iMesh_getTagType, iMesh_HEXAHEDRON, iMesh_PRISM, iMesh_PYRAMID, iMesh_QUADRILATERAL, iMesh_TETRAHEDRON, iMesh_TRIANGLE, INTERNAL_ERROR, MBMesquite::MsqError::INVALID_STATE, meshInstance, MBMesquite::MIXED, MSQ_ERRRTN, MSQ_SETERR, MBMesquite::PRISM, MBMesquite::process_itaps_error(), MBMesquite::PYRAMID, MBMesquite::QUADRILATERAL, size, slavedTag, slavedTagType, MBMesquite::TETRAHEDRON, topologyMap, MBMesquite::TRIANGLE, and MBMesquite::VERTEX_BYTE_TAG_NAME.

Referenced by MsqIMesh().

{
    int ierr;

    // Initialize topology map

    const size_t mapsize = sizeof( topologyMap ) / sizeof( MBMesquite::EntityTopology );
    if( mapsize < iMesh_ALL_TOPOLOGIES )
    {
        MSQ_SETERR( err )
        ( "MsqIMesh needs to be updated for new iMesh element topologies.", MsqError::INTERNAL_ERROR );
    }

    for( size_t i = 0; i <= iMesh_ALL_TOPOLOGIES; ++i )
        topologyMap[i] = MBMesquite::MIXED;

    topologyMap[iMesh_TRIANGLE]      = MBMesquite::TRIANGLE;
    topologyMap[iMesh_QUADRILATERAL] = MBMesquite::QUADRILATERAL;
    topologyMap[iMesh_TETRAHEDRON]   = MBMesquite::TETRAHEDRON;
    topologyMap[iMesh_HEXAHEDRON]    = MBMesquite::HEXAHEDRON;
    topologyMap[iMesh_PRISM]         = MBMesquite::PRISM;
    topologyMap[iMesh_PYRAMID]       = MBMesquite::PYRAMID;

    // Check that fixed tag is valid
    haveFixedTag = false;
    if( fixed_tag )
    {
        fixedTagType = check_valid_flag_tag( *fixed_tag, "fixed", err );MSQ_ERRRTN( err );
        haveFixedTag = true;
        fixedTag     = *fixed_tag;
    }

    // Check that slaved tag is valid
    haveSlavedTag = false;
    if( slaved_tag )
    {
        slavedTagType = check_valid_flag_tag( *slaved_tag, "slaved", err );MSQ_ERRRTN( err );
        haveSlavedTag = true;
        slavedTag     = *slaved_tag;
    }

    // Get/create tag for vertex byte
    iMesh_getTagHandle( meshInstance, VERTEX_BYTE_TAG_NAME, &byteTag, &ierr, strlen( VERTEX_BYTE_TAG_NAME ) );
    if( iBase_SUCCESS != ierr )
    {
        iMesh_createTag( meshInstance, VERTEX_BYTE_TAG_NAME, 1, iBase_INTEGER, &byteTag, &ierr,
                         strlen( VERTEX_BYTE_TAG_NAME ) );
        if( iBase_SUCCESS != ierr )
        {
            MSQ_SETERR( err )
            ( MsqError::INVALID_STATE, "Tag \"%s\" could not be created", VERTEX_BYTE_TAG_NAME );
            return;
        }
        createdByteTag = true;
    }
    else
    {
        int size, type;
        iMesh_getTagSizeBytes( meshInstance, byteTag, &size, &ierr );
        if( iBase_SUCCESS != ierr || size != sizeof( int ) )
        {
            MSQ_SETERR( err )
            ( MsqError::INVALID_STATE, "Tag \"%s\" exists with invalid size", VERTEX_BYTE_TAG_NAME );
            return;
        }
        iMesh_getTagType( meshInstance, byteTag, &type, &ierr );
        if( iBase_SUCCESS != ierr || type != iBase_INTEGER )
        {
            MSQ_SETERR( err )
            ( MsqError::INVALID_STATE, "Tag \"%s\" exists with invalid type", VERTEX_BYTE_TAG_NAME );
            return;
        }
    }
    iMesh_getGeometricDimension( meshInstance, &geometricDimension, &ierr );
    if( iBase_SUCCESS != ierr )
    {
        MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
        return;
    }
}
void MBMesquite::MsqIMesh::release ( ) [virtual]

Instead of deleting a Mesh when you think you are done, call release(). In simple cases, the implementation could just call the destructor. More sophisticated implementations may want to keep the Mesh object to live longer than Mesquite is using it.

Implements MBMesquite::Mesh.

Definition at line 768 of file MsqIMesh.cpp.

{}
void MBMesquite::MsqIMesh::release_entity_handles ( const EntityHandle handle_array,
size_t  num_handles,
MsqError err 
) [virtual]

no-op

Implements MBMesquite::Mesh.

Definition at line 756 of file MsqIMesh.cpp.

{
    // Do nothing
}
void MBMesquite::MsqIMesh::set_active_set ( iBase_EntitySetHandle  meshset,
iBase_EntityType  element_dimension,
MsqError err 
)

set mesh to be smoothed.

Set the mesh which Mesquite is to smooth. Optionally specify fixed vertices. NOTE: If an active set is not specified, the default is to use the global set (the ENTIRE mesh.)

Parameters:
element_setITAPS entity set handle for set containing mesh elements and vertices for which quality is to be improved.

Definition at line 256 of file MsqIMesh.cpp.

References MBMesquite::arrptr(), get_all_vertices(), inputSet, inputSetType, MSQ_CHKERR, MSQ_ERRRTN, vertices_set_byte(), and MBMesquite::zeros.

Referenced by MsqIMesh().

{
    inputSetType = type_in;
    inputSet     = elem_set;

    // clear vertex byte
    std::vector< VertexHandle > verts;
    get_all_vertices( verts, err );MSQ_ERRRTN( err );
    if( !verts.empty() )
    {
        std::vector< unsigned char > zeros( verts.size(), 0 );
        vertices_set_byte( arrptr( verts ), arrptr( zeros ), verts.size(), err );MSQ_CHKERR( err );
    }
}

Set tag for vertex fixed flag.

Definition at line 220 of file MsqIMesh.cpp.

References check_valid_flag_tag(), fixedTag, fixedTagType, haveFixedTag, MSQ_ERRRTN, and t.

{
    iBase_TagValueType t = check_valid_flag_tag( tag, "fixed", err );MSQ_ERRRTN( err );
    fixedTag     = tag;
    fixedTagType = t;
    haveFixedTag = true;
}
void MBMesquite::MsqIMesh::set_int_tag ( void *  tag,
void *  meshset,
int  value,
MsqError err 
) [protected]

Set tag for vertex slaved flag.

Definition at line 238 of file MsqIMesh.cpp.

References check_valid_flag_tag(), haveSlavedTag, MSQ_ERRRTN, slavedTag, slavedTagType, and t.

{
    iBase_TagValueType t = check_valid_flag_tag( tag, "slaved", err );MSQ_ERRRTN( err );
    slavedTag     = tag;
    slavedTagType = t;
    haveSlavedTag = true;
}
TagHandle MBMesquite::MsqIMesh::tag_create ( const std::string &  tag_name,
TagType  type,
unsigned  length,
const void *  default_value,
MsqError err 
) [virtual]

Create a tag.

Create a user-defined data type that can be attached to any element or vertex in the mesh. For an opaque or undefined type, use type=BYTE and length=sizeof(..).

Parameters:
tag_nameA unique name for the data object
typeThe type of the data
lengthNumber of values per entity (1->scalar, >1 ->vector)
default_valueDefault value to assign to all entities - may be NULL
Returns:
- Handle for tag definition

Implements MBMesquite::Mesh.

Definition at line 771 of file MsqIMesh.cpp.

References MBMesquite::Mesh::BYTE, MBMesquite::Mesh::DOUBLE, MBMesquite::Mesh::HANDLE, iBase_BYTES, iBase_DOUBLE, iBase_ENTITY_HANDLE, iBase_INTEGER, iBase_SUCCESS, ierr, iMesh_createTag, MBMesquite::Mesh::INT, INTERNAL_ERROR, MBMesquite::MsqError::INVALID_ARG, MBMesquite::length(), meshInstance, MSQ_SETERR, and MBMesquite::process_itaps_error().

{
    int itaps_type;
    switch( type )
    {
        case MBMesquite::Mesh::BYTE:
            itaps_type = iBase_BYTES;
            break;
        case MBMesquite::Mesh::INT:
            itaps_type = iBase_INTEGER;
            break;
        case MBMesquite::Mesh::DOUBLE:
            itaps_type = iBase_DOUBLE;
            break;
        case MBMesquite::Mesh::HANDLE:
            itaps_type = iBase_ENTITY_HANDLE;
            break;
        default:
            MSQ_SETERR( err )( "Invalid tag type", MsqError::INVALID_ARG );
            return 0;
    }

    int ierr;
    iBase_TagHandle result;
    iMesh_createTag( meshInstance, name.c_str(), length, itaps_type, &result, &ierr, name.size() );
    if( iBase_SUCCESS != ierr )
    {
        MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
        return 0;
    }

    return static_cast< TagHandle >( result );
}
void MBMesquite::MsqIMesh::tag_delete ( TagHandle  handle,
MsqError err 
) [virtual]

Remove a tag and all corresponding data.

Delete a tag.

Implements MBMesquite::Mesh.

Definition at line 805 of file MsqIMesh.cpp.

References iBase_SUCCESS, ierr, iMesh_destroyTag, INTERNAL_ERROR, meshInstance, MSQ_SETERR, and MBMesquite::process_itaps_error().

{
    int ierr;
    iMesh_destroyTag( meshInstance, static_cast< iBase_TagHandle >( handle ), true, &ierr );
    if( iBase_SUCCESS != ierr )
    {
        MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
        return;
    }
}
TagHandle MBMesquite::MsqIMesh::tag_get ( const std::string &  name,
MsqError err 
) [virtual]

Get handle for existing tag, by name.

Implements MBMesquite::Mesh.

Definition at line 816 of file MsqIMesh.cpp.

References iBase_SUCCESS, iBase_TAG_NOT_FOUND, ierr, iMesh_getTagHandle, INTERNAL_ERROR, meshInstance, MSQ_SETERR, MBMesquite::process_itaps_error(), and MBMesquite::MsqError::TAG_NOT_FOUND.

{
    iBase_TagHandle handle = 0;
    int ierr;
    iMesh_getTagHandle( meshInstance, name.c_str(), &handle, &ierr, name.length() );
    if( iBase_TAG_NOT_FOUND == ierr )
    {
        MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::TAG_NOT_FOUND );
        return 0;
    }
    else if( iBase_SUCCESS != ierr )
    {
        MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
        return 0;
    }
    return static_cast< TagHandle >( handle );
}
void MBMesquite::MsqIMesh::tag_get_data ( TagHandle  handle,
size_t  num_elems,
const EntityHandle handle_array,
void *  tag_data,
MsqError err 
) [private]

Get tag values.

Definition at line 943 of file MsqIMesh.cpp.

References iBase_SUCCESS, ierr, iMesh_getArrData, iMesh_getTagSizeBytes, INTERNAL_ERROR, meshInstance, MSQ_SETERR, MBMesquite::process_itaps_error(), and size.

Referenced by tag_get_element_data(), and tag_get_vertex_data().

{
    int ierr, size;
    iMesh_getTagSizeBytes( meshInstance, static_cast< iBase_TagHandle >( tag ), &size, &ierr );
    if( iBase_SUCCESS != ierr )
    {
        MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
        return;
    }
#if IMESH_VERSION_ATLEAST( 1, 1 )
    void* ptr = data;
#else
    char* ptr = static_cast< char* >( data );
#endif
    int junk1 = size * num_elems, junk2;
    assert( sizeof( EntityHandle ) == sizeof( iBase_EntityHandle ) );
    const iBase_EntityHandle* arr = reinterpret_cast< const iBase_EntityHandle* >( array );
    iMesh_getArrData( meshInstance, arr, num_elems, static_cast< iBase_TagHandle >( tag ), &ptr, &junk1, &junk2,
                      &ierr );
    if( iBase_SUCCESS != ierr )
    {
        MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
        return;
    }
}
void MBMesquite::MsqIMesh::tag_get_element_data ( TagHandle  handle,
size_t  num_elems,
const ElementHandle elem_array,
void *  tag_data,
MsqError err 
) [virtual]

Get tag values on elements.

Get the value of a tag for a list of mesh elements.

Parameters:
handleThe tag
num_elemsLength of elem_array
elem_arrayArray of elements for which to get the tag value.
tag_dataReturn buffer in which to copy tag data, contiguous in memory. This data is expected to be num_elems*tag_length*sizeof(tag_type) bytes.

Implements MBMesquite::Mesh.

Definition at line 925 of file MsqIMesh.cpp.

References tag_get_data().

{
    tag_get_data( tag, num_elems, array, data, err );
}
void MBMesquite::MsqIMesh::tag_get_vertex_data ( TagHandle  handle,
size_t  num_elems,
const VertexHandle node_array,
void *  tag_data,
MsqError err 
) [virtual]

Get tag values on vertices.

Get the value of a tag for a list of mesh vertices.

Parameters:
handleThe tag
num_elemsLength of elem_array
elem_arrayArray of vertices for which to get the tag value.
tag_dataReturn buffer in which to copy tag data, contiguous in memory. This data is expected to be num_elems*tag_length*sizeof(tag_type) bytes.

Implements MBMesquite::Mesh.

Definition at line 934 of file MsqIMesh.cpp.

References tag_get_data().

{
    tag_get_data( tag, num_elems, array, data, err );
}
void MBMesquite::MsqIMesh::tag_properties ( TagHandle  handle,
std::string &  name_out,
TagType type_out,
unsigned &  length_out,
MsqError err 
) [virtual]

Get properites of tag.

Get data type and number of values per entity for tag.

Parameters:
handleTag to get properties of.
name_outPassed back tag name.
type_outPassed back tag type.
length_outPassed back number of values per entity.

Implements MBMesquite::Mesh.

Definition at line 834 of file MsqIMesh.cpp.

References buffer, MBMesquite::Mesh::BYTE, MBMesquite::Mesh::DOUBLE, MBMesquite::Mesh::HANDLE, iBase_BYTES, iBase_DOUBLE, iBase_ENTITY_HANDLE, iBase_INTEGER, iBase_SUCCESS, ierr, iMesh_getTagName, iMesh_getTagSizeValues, iMesh_getTagType, MBMesquite::Mesh::INT, INTERNAL_ERROR, meshInstance, MSQ_SETERR, NOT_IMPLEMENTED, and MBMesquite::process_itaps_error().

{
    char buffer[256];
    int ierr1, ierr2, ierr3, itype;

    iBase_TagHandle th = static_cast< iBase_TagHandle >( handle );
    iMesh_getTagName( meshInstance, th, buffer, &ierr1, sizeof( buffer ) );
    iMesh_getTagSizeValues( meshInstance, th, (int*)&length_out, &ierr2 );
    iMesh_getTagType( meshInstance, th, &itype, &ierr3 );

    int ierr = iBase_SUCCESS;
    if( ierr1 != iBase_SUCCESS )
        ierr = ierr1;
    else if( ierr2 != iBase_SUCCESS )
        ierr = ierr2;
    else if( ierr3 != iBase_SUCCESS )
        ierr = ierr3;
    if( iBase_SUCCESS != ierr )
    {
        MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
        return;
    }

    buffer[255] = '\0';
    name_out    = buffer;
    switch( itype )
    {
        case iBase_BYTES:
            type_out = MBMesquite::Mesh::BYTE;
            break;
        case iBase_INTEGER:
            type_out = MBMesquite::Mesh::INT;
            break;
        case iBase_DOUBLE:
            type_out = MBMesquite::Mesh::DOUBLE;
            break;
        case iBase_ENTITY_HANDLE:
            type_out = MBMesquite::Mesh::HANDLE;
            break;
        default:
            MSQ_SETERR( err )( "Unsupported iMesh tag type", MsqError::NOT_IMPLEMENTED );
            return;
    }
}
void MBMesquite::MsqIMesh::tag_set_data ( TagHandle  handle,
size_t  num_elems,
const EntityHandle handle_array,
const void *  tag_data,
MsqError err 
) [private]

Set tag values.

Definition at line 901 of file MsqIMesh.cpp.

References iBase_SUCCESS, ierr, iMesh_getTagSizeBytes, iMesh_setArrData, INTERNAL_ERROR, meshInstance, MSQ_SETERR, MBMesquite::process_itaps_error(), and size.

Referenced by tag_set_element_data(), and tag_set_vertex_data().

{
    int ierr, size;
    iMesh_getTagSizeBytes( meshInstance, static_cast< iBase_TagHandle >( tag ), &size, &ierr );
    if( iBase_SUCCESS != ierr )
    {
        MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
        return;
    }
    assert( sizeof( EntityHandle ) == sizeof( iBase_EntityHandle ) );
    const iBase_EntityHandle* arr = reinterpret_cast< const iBase_EntityHandle* >( array );
    iMesh_setArrData( meshInstance, arr, num_elems, static_cast< iBase_TagHandle >( tag ),
                      static_cast< const char* >( data ), size * num_elems, &ierr );
    if( iBase_SUCCESS != ierr )
    {
        MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
        return;
    }
}
void MBMesquite::MsqIMesh::tag_set_element_data ( TagHandle  handle,
size_t  num_elems,
const ElementHandle elem_array,
const void *  tag_data,
MsqError err 
) [virtual]

Set tag values on elements.

Set the value of a tag for a list of mesh elements.

Parameters:
handleThe tag
num_elemsLength of elem_array
elem_arrayArray of elements for which to set the tag value.
tag_dataTag data for each element, contiguous in memory. This data is expected to be

num_elems*tag_length*sizeof(tag_type) bytes.

Implements MBMesquite::Mesh.

Definition at line 883 of file MsqIMesh.cpp.

References tag_set_data().

{
    tag_set_data( tag, num_elems, array, data, err );
}
void MBMesquite::MsqIMesh::tag_set_vertex_data ( TagHandle  handle,
size_t  num_elems,
const VertexHandle node_array,
const void *  tag_data,
MsqError err 
) [virtual]

Set tag values on vertices.

Set the value of a tag for a list of mesh vertices.

Parameters:
handleThe tag
num_elemsLength of node_array
node_arrayArray of vertices for which to set the tag value.
tag_dataTag data for each element, contiguous in memory. This data is expected to be num_elems*tag_length*sizeof(tag_type) bytes.

Implements MBMesquite::Mesh.

Definition at line 892 of file MsqIMesh.cpp.

References tag_set_data().

{
    tag_set_data( tag, num_elems, array, data, err );
}
void MBMesquite::MsqIMesh::vertex_get_byte ( VertexHandle  vertex,
unsigned char *  byte,
MsqError err 
) [virtual]

Get vertex mark.

Implements MBMesquite::Mesh.

Definition at line 441 of file MsqIMesh.cpp.

References byteTag, iBase_SUCCESS, ierr, iMesh_getIntData, INTERNAL_ERROR, meshInstance, MSQ_SETERR, MBMesquite::process_itaps_error(), and value().

{
    int ierr, value;
    iBase_EntityHandle bh = static_cast< iBase_EntityHandle >( vertex );
    iMesh_getIntData( meshInstance, bh, byteTag, &value, &ierr );
    if( iBase_SUCCESS != ierr ) MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
    *byte = value;
}
void MBMesquite::MsqIMesh::vertex_set_byte ( VertexHandle  vertex,
unsigned char  byte,
MsqError err 
) [virtual]
void MBMesquite::MsqIMesh::vertex_set_coordinates ( VertexHandle  vertex,
const Vector3D coordinates,
MsqError err 
) [virtual]

Set vertex coordinates.

Implements MBMesquite::Mesh.

Definition at line 402 of file MsqIMesh.cpp.

References iBase_SUCCESS, ierr, iMesh_setVtxCoord, INTERNAL_ERROR, meshInstance, MSQ_SETERR, and MBMesquite::process_itaps_error().

{
    int ierr;
    iBase_EntityHandle bh = static_cast< iBase_EntityHandle >( vertex );
    iMesh_setVtxCoord( meshInstance, bh, coords[0], coords[1], coords[2], &ierr );
    if( iBase_SUCCESS != ierr ) MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
}
void MBMesquite::MsqIMesh::vertices_get_attached_elements ( const VertexHandle vertex_array,
size_t  num_vertices,
std::vector< ElementHandle > &  elements,
std::vector< size_t > &  offsets,
MsqError err 
) [virtual]

Get vertex-to-element adjacencies.

Implements MBMesquite::Mesh.

Definition at line 562 of file MsqIMesh.cpp.

References get_adjacent_entities(), iBase_SUCCESS, ierr, iMesh_getRootSet, iMesh_isEntContained, inputSet, inputSetType, INTERNAL_ERROR, meshInstance, MSQ_ERRRTN, MSQ_SETERR, MBMesquite::process_itaps_error(), and root_set.

{
    int ierr, cont;
    assert( sizeof( EntityHandle ) == sizeof( iBase_EntityHandle ) );
    const iBase_EntityHandle* verts = reinterpret_cast< const iBase_EntityHandle* >( vertices );
    get_adjacent_entities( verts, num_vertex, inputSetType, elements, offsets, err );MSQ_ERRRTN( err );

    iBase_EntitySetHandle root_set;
    iMesh_getRootSet( meshInstance, &root_set, &ierr );
    if( iBase_SUCCESS != ierr )
    {
        MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
        return;
    }

    // Remove all elements not in inputSet
    if( root_set != inputSet )
    {
        std::vector< size_t >::iterator offset_iter = offsets.begin();
        size_t read_idx, write_idx;
        for( read_idx = write_idx = 0; read_idx < elements.size(); ++read_idx )
        {
            if( *offset_iter == read_idx )
            {
                *offset_iter = write_idx;
                ++offset_iter;
            }

            iBase_EntityHandle bh = static_cast< iBase_EntityHandle >( elements[read_idx] );
            iMesh_isEntContained( meshInstance, inputSet, bh, &cont, &ierr );
            if( iBase_SUCCESS != ierr )
            {
                MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
                return;
            }

            if( cont ) elements[write_idx++] = elements[read_idx];
        }
        *offset_iter = write_idx;
        elements.resize( write_idx );
    }
}
void MBMesquite::MsqIMesh::vertices_get_byte ( const VertexHandle vert_array,
unsigned char *  byte_array,
size_t  array_size,
MsqError err 
) [virtual]

Get vertex mark.

Implements MBMesquite::Mesh.

Definition at line 450 of file MsqIMesh.cpp.

References MBMesquite::arrptr(), byteTag, iBase_SUCCESS, ierr, iMesh_getIntArrData, INTERNAL_ERROR, meshInstance, MSQ_SETERR, and MBMesquite::process_itaps_error().

{
    if( !array_size ) return;

    std::vector< int > data( array_size );
    int ierr;
    int* ptr  = arrptr( data );
    int junk1 = data.size(), junk2;
    assert( sizeof( VertexHandle ) == sizeof( iBase_EntityHandle ) );
    const iBase_EntityHandle* arr = reinterpret_cast< const iBase_EntityHandle* >( vert_array );
    iMesh_getIntArrData( meshInstance, arr, array_size, byteTag, &ptr, &junk1, &junk2, &ierr );
    if( iBase_SUCCESS != ierr ) MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
    std::copy( data.begin(), data.end(), byte_array );
}
void MBMesquite::MsqIMesh::vertices_get_coordinates ( const VertexHandle  vert_array[],
MsqVertex coordinates,
size_t  num_vtx,
MsqError err 
) [virtual]

Get vertex coordinates.

Implements MBMesquite::Mesh.

Definition at line 359 of file MsqIMesh.cpp.

References MBMesquite::arrptr(), geometricDimension, iBase_INTERLEAVED, iBase_SUCCESS, ierr, iMesh_getVtxArrCoords, INTERNAL_ERROR, meshInstance, MSQ_SETERR, MBMesquite::process_itaps_error(), MBMesquite::Vector3D::set(), MBMesquite::Vector3D::x(), MBMesquite::Vector3D::y(), and MBMesquite::Vector3D::z().

{
    if( !num_vtx ) return;

    std::vector< double > dbl_store( 3 * num_vtx );
    double* dbl_array = arrptr( dbl_store );

    int ierr, junk = 3 * num_vtx, junk2;
    assert( sizeof( VertexHandle ) == sizeof( iBase_EntityHandle ) );
    const iBase_EntityHandle* arr = reinterpret_cast< const iBase_EntityHandle* >( vert_array );
    iMesh_getVtxArrCoords( meshInstance, arr, num_vtx, iBase_INTERLEAVED, &dbl_array, &junk, &junk2, &ierr );
    if( iBase_SUCCESS != ierr )
    {
        MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
        return;
    }

    if( geometricDimension == 2 )
    {
        double* iter = dbl_array;
        for( size_t i = 0; i < num_vtx; ++i )
        {
            coordinates[i].x( *iter );
            ++iter;
            coordinates[i].y( *iter );
            ++iter;
            coordinates[i].z( 0 );
        }
    }
    else
    {
        double* iter = dbl_array;
        for( size_t i = 0; i < num_vtx; ++i )
        {
            coordinates[i].set( iter );
            iter += 3;
        }
    }
}
void MBMesquite::MsqIMesh::vertices_get_fixed_flag ( const VertexHandle  vert_array[],
std::vector< bool > &  fixed_flag_array,
size_t  num_vtx,
MsqError err 
) [virtual]

Query "fixed" flag for a vertex.

Implements MBMesquite::Mesh.

Definition at line 342 of file MsqIMesh.cpp.

References fixedTag, fixedTagType, get_flag_data(), and haveFixedTag.

{
    get_flag_data( fixedTag, haveFixedTag, fixedTagType, vert_array, bool_array, num_vtx, err );
}
void MBMesquite::MsqIMesh::vertices_get_slaved_flag ( const VertexHandle  vert_array[],
std::vector< bool > &  slaved_flag_array,
size_t  num_vtx,
MsqError err 
) [virtual]

Returns true or false, indicating whether the vertex is a higher-order node that should be slaved to the logical mid-point of the element side it lies on or not, respectively.

Note: This function will never be called unless this behavior is requested by calling: InstructionQueue::set_slaved_ho_node_mode( Settings::SLAVE_FLAG )

Implements MBMesquite::Mesh.

Definition at line 350 of file MsqIMesh.cpp.

References get_flag_data(), haveSlavedTag, slavedTag, and slavedTagType.

{
    get_flag_data( slavedTag, haveSlavedTag, slavedTagType, vert_array, bool_array, num_vtx, err );
}
void MBMesquite::MsqIMesh::vertices_set_byte ( const VertexHandle vert_array,
const unsigned char *  byte_array,
size_t  array_size,
MsqError err 
) [virtual]

Set vertex mark.

Implements MBMesquite::Mesh.

Definition at line 422 of file MsqIMesh.cpp.

References MBMesquite::arrptr(), byteTag, iBase_SUCCESS, ierr, iMesh_setIntArrData, INTERNAL_ERROR, meshInstance, MSQ_SETERR, and MBMesquite::process_itaps_error().

Referenced by set_active_set().

{
    if( !array_size ) return;

    std::vector< int > data( array_size );
    std::copy( byte_array, byte_array + array_size, data.begin() );
    int ierr;
    assert( sizeof( VertexHandle ) == sizeof( iBase_EntityHandle ) );
    const iBase_EntityHandle* arr = reinterpret_cast< const iBase_EntityHandle* >( vert_array );
    iMesh_setIntArrData( meshInstance, arr, array_size, byteTag, arrptr( data ), array_size, &ierr );
    if( iBase_SUCCESS != ierr ) MSQ_SETERR( err )( process_itaps_error( ierr ), MsqError::INTERNAL_ERROR );
}

Member Data Documentation

Handle for tag used to hold vertex byte

Definition at line 430 of file MsqIMesh.hpp.

Referenced by init_active_mesh(), vertex_get_byte(), vertex_set_byte(), vertices_get_byte(), vertices_set_byte(), and ~MsqIMesh().

Tag was created in constructor

Definition at line 432 of file MsqIMesh.hpp.

Referenced by init_active_mesh(), and ~MsqIMesh().

Handle for tag used to hold vertex-fixed flag

Definition at line 434 of file MsqIMesh.hpp.

Referenced by get_fixed_tag(), init_active_mesh(), set_fixed_tag(), and vertices_get_fixed_flag().

iBase_TYPE for fixed tag

Definition at line 438 of file MsqIMesh.hpp.

Referenced by init_active_mesh(), set_fixed_tag(), and vertices_get_fixed_flag().

Dimension is queried once during create and cached

Definition at line 446 of file MsqIMesh.hpp.

Referenced by get_geometric_dimension(), init_active_mesh(), and vertices_get_coordinates().

fixedTag handle is valid

Definition at line 436 of file MsqIMesh.hpp.

Referenced by clear_fixed_tag(), get_fixed_tag(), init_active_mesh(), set_fixed_tag(), and vertices_get_fixed_flag().

Have mesh

Definition at line 408 of file MsqIMesh.hpp.

slavedTag handle is valid

Definition at line 442 of file MsqIMesh.hpp.

Referenced by clear_slaved_tag(), get_slaved_tag(), init_active_mesh(), set_slaved_tag(), and vertices_get_slaved_flag().

The meshset containing the elements to optimize

Definition at line 427 of file MsqIMesh.hpp.

Referenced by get_all_elements(), get_entity_set(), set_active_set(), and vertices_get_attached_elements().

ITAPS entity set handle for elements to improve ITAPS entity set handle for nodes to move std::set containing elements in elementSet, used to constrain vertex->element adjaceny queries to only those elements that are in the input element set. The type of elements contained in the input element set. Should be one of:

  • iBase_REGION - volume elements
  • iBase_FACE - face/2d elements
  • iBase_ALL_TYPES - mixed volume and face elements

Definition at line 425 of file MsqIMesh.hpp.

Referenced by get_all_elements(), set_active_set(), and vertices_get_attached_elements().

Handle for tag used to hold vertex-slaved flag

Definition at line 440 of file MsqIMesh.hpp.

Referenced by get_slaved_tag(), init_active_mesh(), set_slaved_tag(), and vertices_get_slaved_flag().

iBase_TYPE for slaved tag

Definition at line 444 of file MsqIMesh.hpp.

Referenced by init_active_mesh(), set_slaved_tag(), and vertices_get_slaved_flag().

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