MOAB: Mesh Oriented datABase  (version 5.4.1)
GetEntities.cpp File Reference
#include "moab/Core.hpp"
#include "moab/Range.hpp"
#include "moab/CN.hpp"
#include <iostream>
+ Include dependency graph for GetEntities.cpp:

Go to the source code of this file.

Defines

#define MESH_DIR   "."

Functions

int main (int argc, char **argv)

Variables

string test_file_name = string( MESH_DIR ) + string( "/hex01.vtk" )

Define Documentation

#define MESH_DIR   "."

Definition at line 18 of file GetEntities.cpp.


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 23 of file GetEntities.cpp.

References moab::Range::begin(), moab::Range::end(), moab::CN::EntityTypeName(), ErrorCode, moab::Core::get_adjacencies(), moab::Core::get_connectivity(), moab::Core::get_entities_by_handle(), moab::Core::id_from_handle(), moab::Core::load_mesh(), mb, MB_CHK_ERR, MBENTITYSET, MBVERTEX, moab::Range::print(), test_file_name, and moab::Core::type_from_handle().

{
    if( argc > 1 )
    {
        // User has input a mesh file
        test_file_name = argv[1];
    }

    // Instantiate & load a mesh from a file
    Core* mb = new( std::nothrow ) Core;
    if( NULL == mb ) return 1;
    ErrorCode rval = mb->load_mesh( test_file_name.c_str() );MB_CHK_ERR( rval );

    Range ents;

    // Get all entities in the database
    rval = mb->get_entities_by_handle( 0, ents );MB_CHK_ERR( rval );

    for( Range::iterator it = ents.begin(); it != ents.end(); ++it )
    {
        if( MBVERTEX == mb->type_from_handle( *it ) )
        {
            Range adjs;
            rval = mb->get_adjacencies( &( *it ), 1, 3, false, adjs );MB_CHK_ERR( rval );
            cout << "Vertex " << mb->id_from_handle( *it ) << " adjacencies:" << endl;
            adjs.print();
        }
        else if( mb->type_from_handle( *it ) < MBENTITYSET )
        {
            const EntityHandle* connect;
            int num_connect;
            rval = mb->get_connectivity( *it, connect, num_connect );MB_CHK_ERR( rval );
            cout << CN::EntityTypeName( mb->type_from_handle( *it ) ) << " " << mb->id_from_handle( *it )
                 << " vertex connectivity is: ";
            for( int i = 0; i < num_connect; i++ )
                cout << mb->id_from_handle( connect[i] ) << " ";
            cout << endl;
        }
    }

    delete mb;

    return 0;
}

Variable Documentation

string test_file_name = string( MESH_DIR ) + string( "/hex01.vtk" )

Definition at line 21 of file GetEntities.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines