MOAB: Mesh Oriented datABase  (version 5.2.1)
test_adj.cpp File Reference
#include <iostream>
#include "moab/Core.hpp"
#include "TestUtil.hpp"
#include "Internals.hpp"
+ Include dependency graph for test_adj.cpp:

Go to the source code of this file.

Functions

int main ()

Function Documentation

int main ( )

Definition at line 37 of file test_adj.cpp.

References moab::Range::begin(), CHECK_EQUAL, CHECK_ERR, conn, moab::CREATE_HANDLE(), moab::Range::end(), moab::error(), filename, moab::ID_FROM_HANDLE(), iface, MB_START_ID, and MBQUAD.

{
    Interface* iface = new Core;

    std::string filename;

#ifdef MOAB_HAVE_HDF5
    filename = TestDir + "/testquad-cyl.h5m";
#else
    filename = TestDir + "/hexes_mixed.vtk";
#endif

    ErrorCode err;
    err = iface->load_mesh( filename.c_str() );CHECK_ERR( err );

    Range quads, verts;
    err = iface->get_entities_by_dimension( 0, 0, verts );CHECK_ERR( err );
    err = iface->get_entities_by_dimension( 0, 2, quads );CHECK_ERR( err );

    for( Range::iterator it = verts.begin(); it != verts.end(); it++ )
        std::cout << "verts[" << ( *it - *verts.begin() ) << "] = " << *it << std::endl;

    std::vector< EntityHandle > conn;
    for( Range::iterator it = quads.begin(); it != quads.end(); it++ )
    {
        conn.clear();
        err = iface->get_connectivity( &*it, 1, conn );CHECK_ERR( err );
        std::cout << "quads[" << ( *it - *quads.begin() ) << "] = " << *it << " :: conn = [" << conn[0] << ", "
                  << conn[1] << ", " << conn[2] << ", " << conn[3] << "]" << std::endl;
    }

    std::vector< EntityHandle > nodes;
    int error;
    EntityHandle h = CREATE_HANDLE( MBQUAD, MB_START_ID, error );
    CHECK_EQUAL( 0, error );
    std::cout << "h = " << h << std::endl;

    err = iface->get_adjacencies( &h, 1, 0, true, nodes );CHECK_ERR( err );

    for( int i = 0; i < (int)nodes.size(); i++ )
        std::cout << "nodes[" << i << "] = " << nodes[i] << " ";
    std::cout << std::endl;

    std::vector< EntityHandle > edgs;
    err = iface->get_adjacencies( &h, 1, 1, true, edgs );CHECK_ERR( err );

    for( int i = 0; i < (int)edgs.size(); i++ )
        std::cout << "edgs[" << i << "] = " << edgs[i] << " ";
    std::cout << std::endl;

    // faces to nodes

    for( unsigned int i = 0; i < edgs.size(); i++ )
    {
        nodes.clear();
        err = iface->get_adjacencies( &edgs[i], 1, 0, true, nodes );CHECK_ERR( err );
        std::cout << "edge " << ID_FROM_HANDLE( edgs[i] ) << std::endl;
        std::cout << "nodes = ";
        for( unsigned int j = 0; j < nodes.size(); j++ )
            std::cout << nodes[j] << " ";
        std::cout << std::endl;
    }

    delete iface;

    return 0;
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines