MOAB: Mesh Oriented datABase  (version 5.2.1)
UnstructuredElemSeq.cpp
Go to the documentation of this file.
00001 #include "UnstructuredElemSeq.hpp"
00002 #include "SequenceData.hpp"
00003 #include "moab/CN.hpp"
00004 
00005 namespace moab
00006 {
00007 
00008 UnstructuredElemSeq::UnstructuredElemSeq( EntityHandle shandle, EntityID entity_count, unsigned nodes_per_entity,
00009                                           SequenceData* dat )
00010     : ElementSequence( shandle, entity_count, nodes_per_entity, dat )
00011 {
00012 }
00013 
00014 UnstructuredElemSeq::UnstructuredElemSeq( EntityHandle shandle, EntityID entity_count, unsigned nodes_per_entity,
00015                                           EntityID data_size )
00016     : ElementSequence( shandle, entity_count, nodes_per_entity,
00017                        new SequenceData( 1, shandle, shandle + data_size - 1 ) )
00018 {
00019     data()->create_sequence_data( 0, nodes_per_entity * sizeof( EntityHandle ) );
00020 }
00021 
00022 UnstructuredElemSeq::~UnstructuredElemSeq() {}
00023 
00024 int UnstructuredElemSeq::values_per_entity() const
00025 {
00026     return nodes_per_element();
00027 }
00028 
00029 EntitySequence* UnstructuredElemSeq::split( EntityHandle here )
00030 {
00031     if( here <= start_handle() || here > end_handle() ) return 0;
00032 
00033     return new UnstructuredElemSeq( *this, here );
00034 }
00035 
00036 SequenceData* UnstructuredElemSeq::create_data_subset( EntityHandle start, EntityHandle end ) const
00037 {
00038     int esize = nodes_per_element() * sizeof( EntityHandle );
00039     return data()->subset( start, end, &esize );
00040 }
00041 
00042 void UnstructuredElemSeq::get_const_memory_use( unsigned long& bytes_per_entity, unsigned long& size_of_sequence ) const
00043 {
00044     bytes_per_entity = nodes_per_element() * sizeof( EntityHandle );
00045     size_of_sequence = sizeof( *this );
00046 }
00047 
00048 ErrorCode UnstructuredElemSeq::get_connectivity( EntityHandle handle, std::vector< EntityHandle >& connect,
00049                                                  bool topological ) const
00050 {
00051     EntityHandle const* conn = get_array() + nodes_per_element() * ( handle - start_handle() );
00052     int len                  = topological ? CN::VerticesPerEntity( type() ) : nodes_per_element();
00053     connect.reserve( connect.size() + len );
00054     std::copy( conn, conn + len, std::back_inserter( connect ) );
00055     return MB_SUCCESS;
00056 }
00057 
00058 ErrorCode UnstructuredElemSeq::get_connectivity( EntityHandle handle, EntityHandle const*& conn_ptr, int& len,
00059                                                  bool topological, std::vector< EntityHandle >* ) const
00060 {
00061     conn_ptr = get_array() + nodes_per_element() * ( handle - start_handle() );
00062     len      = topological ? CN::VerticesPerEntity( type() ) : nodes_per_element();
00063     return MB_SUCCESS;
00064 }
00065 
00066 ErrorCode UnstructuredElemSeq::set_connectivity( EntityHandle handle, EntityHandle const* connect, int connect_length )
00067 {
00068     if( (unsigned)connect_length != nodes_per_element() ) return MB_INDEX_OUT_OF_RANGE;
00069     EntityHandle* conn_ptr = get_array() + nodes_per_element() * ( handle - start_handle() );
00070     std::copy( connect, connect + connect_length, conn_ptr );
00071     return MB_SUCCESS;
00072 }
00073 
00074 EntityHandle* UnstructuredElemSeq::get_connectivity_array()
00075 {
00076     return get_array();
00077 }
00078 
00079 ErrorCode UnstructuredElemSeq::push_back( EntityID count )
00080 {
00081     return EntitySequence::append_entities( count );
00082 }
00083 
00084 ErrorCode UnstructuredElemSeq::push_front( EntityID count )
00085 {
00086     return EntitySequence::prepend_entities( count );
00087 }
00088 
00089 }  // namespace moab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines