MOAB: Mesh Oriented datABase  (version 5.4.1)
test_adj.cpp
Go to the documentation of this file.
00001 /**
00002  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
00003  * storing and accessing finite element mesh data.
00004  *
00005  * Copyright 2004 Sandia Corporation.  Under the terms of Contract
00006  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
00007  * retains certain rights in this software.
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  *
00014  */
00015 
00016 #ifdef WIN32
00017 #ifdef _DEBUG
00018 // turn off warnings that say they debugging identifier has been truncated
00019 // this warning comes up when using some STL containers
00020 #pragma warning( disable : 4786 )
00021 #endif
00022 #endif
00023 
00024 #include <iostream>
00025 #include "moab/Core.hpp"
00026 #include "TestUtil.hpp"
00027 
00028 #ifndef IS_BUILDING_MB
00029 #define IS_BUILDING_MB
00030 #endif
00031 
00032 #include "Internals.hpp"
00033 #include "TestUtil.hpp"
00034 
00035 using namespace moab;
00036 
00037 int main()
00038 {
00039     Interface* iface = new Core;
00040 
00041     std::string filename;
00042 
00043 #ifdef MOAB_HAVE_HDF5
00044     filename = TestDir + "unittest/testquad-cyl.h5m";
00045 #else
00046     filename = TestDir + "unittest/hexes_mixed.vtk";
00047 #endif
00048 
00049     ErrorCode err;
00050     err = iface->load_mesh( filename.c_str() );CHECK_ERR( err );
00051 
00052     Range quads, verts;
00053     err = iface->get_entities_by_dimension( 0, 0, verts );CHECK_ERR( err );
00054     err = iface->get_entities_by_dimension( 0, 2, quads );CHECK_ERR( err );
00055 
00056     for( Range::iterator it = verts.begin(); it != verts.end(); it++ )
00057         std::cout << "verts[" << ( *it - *verts.begin() ) << "] = " << *it << std::endl;
00058 
00059     std::vector< EntityHandle > conn;
00060     for( Range::iterator it = quads.begin(); it != quads.end(); it++ )
00061     {
00062         conn.clear();
00063         err = iface->get_connectivity( &*it, 1, conn );CHECK_ERR( err );
00064         std::cout << "quads[" << ( *it - *quads.begin() ) << "] = " << *it << " :: conn = [" << conn[0] << ", "
00065                   << conn[1] << ", " << conn[2] << ", " << conn[3] << "]" << std::endl;
00066     }
00067 
00068     std::vector< EntityHandle > nodes;
00069     int error;
00070     EntityHandle h = CREATE_HANDLE( MBQUAD, MB_START_ID, error );
00071     CHECK_EQUAL( 0, error );
00072     std::cout << "h = " << h << std::endl;
00073 
00074     err = iface->get_adjacencies( &h, 1, 0, true, nodes );CHECK_ERR( err );
00075 
00076     for( int i = 0; i < (int)nodes.size(); i++ )
00077         std::cout << "nodes[" << i << "] = " << nodes[i] << " ";
00078     std::cout << std::endl;
00079 
00080     std::vector< EntityHandle > edgs;
00081     err = iface->get_adjacencies( &h, 1, 1, true, edgs );CHECK_ERR( err );
00082 
00083     for( int i = 0; i < (int)edgs.size(); i++ )
00084         std::cout << "edgs[" << i << "] = " << edgs[i] << " ";
00085     std::cout << std::endl;
00086 
00087     // faces to nodes
00088 
00089     for( unsigned int i = 0; i < edgs.size(); i++ )
00090     {
00091         nodes.clear();
00092         err = iface->get_adjacencies( &edgs[i], 1, 0, true, nodes );CHECK_ERR( err );
00093         std::cout << "edge " << ID_FROM_HANDLE( edgs[i] ) << std::endl;
00094         std::cout << "nodes = ";
00095         for( unsigned int j = 0; j < nodes.size(); j++ )
00096             std::cout << nodes[j] << " ";
00097         std::cout << std::endl;
00098     }
00099 
00100     delete iface;
00101 
00102     return 0;
00103 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines