[MOAB-dev] r1286 - MOAB/trunk
kraftche at mcs.anl.gov
kraftche at mcs.anl.gov
Tue Sep 25 11:56:03 CDT 2007
Author: kraftche
Date: 2007-09-25 11:56:03 -0500 (Tue, 25 Sep 2007)
New Revision: 1286
Removed:
MOAB/trunk/MBFileReadTool.cpp
MOAB/trunk/MBFileReadTool.hpp
MOAB/trunk/README.RefCount
MOAB/trunk/RangeMap.hpp
MOAB/trunk/RangeMapTest.cpp
Modified:
MOAB/trunk/AEntityFactory.cpp
MOAB/trunk/AEntityFactory.hpp
MOAB/trunk/EntitySequence.cpp
MOAB/trunk/EntitySequence.hpp
MOAB/trunk/EntitySequenceManager.hpp
MOAB/trunk/HigherOrderFactory.cpp
MOAB/trunk/MBCore.cpp
MOAB/trunk/MBCore.hpp
MOAB/trunk/MBMeshSet.cpp
MOAB/trunk/MBMeshSet.hpp
MOAB/trunk/MBReadUtil.cpp
MOAB/trunk/MBReadUtil.hpp
MOAB/trunk/MBReadUtilIface.hpp
MOAB/trunk/MBTest.cpp
MOAB/trunk/Makefile.am
MOAB/trunk/MeshSetSequence.cpp
MOAB/trunk/MeshSetSequence.hpp
MOAB/trunk/PolyEntitySequence.cpp
MOAB/trunk/ReadGmsh.cpp
MOAB/trunk/ReadHDF5.cpp
MOAB/trunk/ReadNCDF.cpp
MOAB/trunk/ReadSTL.cpp
MOAB/trunk/ReadVtk.cpp
MOAB/trunk/TagServer.cpp
MOAB/trunk/TagServer.hpp
MOAB/trunk/configure.in
Log:
back out changes from trunk that should have been checked into branckes
Modified: MOAB/trunk/AEntityFactory.cpp
===================================================================
--- MOAB/trunk/AEntityFactory.cpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/AEntityFactory.cpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -17,7 +17,7 @@
#include "AEntityFactory.hpp"
#include "MBInternals.hpp"
-#include "MBCore.hpp"
+#include "MBInterface.hpp"
#include "MBRange.hpp"
#include "MBError.hpp"
#include "MBCN.hpp"
@@ -27,51 +27,9 @@
#include <algorithm>
#include <set>
-#ifdef MOAB_WITH_REFCOUNT
-MBErrorCode AEntityFactory::decrement_reference_count( const MBEntityHandle* arr, size_t len )
- { return thisMB->decrement_reference_count( arr, len ); }
-MBErrorCode AEntityFactory::increment_reference_count( const MBEntityHandle* arr, size_t len )
- { return thisMB->increment_reference_count( arr, len ); }
-MBErrorCode AEntityFactory::decrement_referenced_entities( MBEntityHandle h )
-{
- const MBEntityHandle* adj;
- int num_adj;
- MBErrorCode rval = get_adjacencies( h, adj, num_adj );
- if (MB_SUCCESS != rval || num_adj == 0)
- return rval;
-
- MBEntityType type = TYPE_FROM_HANDLE(h);
- if (type == MBVERTEX)
- return MB_SUCCESS;
- --type;
-
- int junk;
- const MBEntityHandle* end
- = std::lower_bound( adj, adj+num_adj, CREATE_HANDLE( type, 0, junk ) );
- return decrement_reference_count( adj, end - adj );
-}
-MBErrorCode AEntityFactory::increment_referenced_entities( MBEntityHandle h )
-{
- const MBEntityHandle* adj;
- int num_adj;
- MBErrorCode rval = get_adjacencies( h, adj, num_adj );
- if (MB_SUCCESS != rval || num_adj == 0)
- return rval;
-
- MBEntityType type = TYPE_FROM_HANDLE(h);
- if (type == MBVERTEX)
- return MB_SUCCESS;
- --type;
-
- int junk;
- const MBEntityHandle* end
- = std::lower_bound( adj, adj+num_adj, CREATE_HANDLE( type, 0, junk ) );
- return increment_reference_count( adj, end - adj );
-}
-#endif
-AEntityFactory::AEntityFactory(MBCore *mdb)
+AEntityFactory::AEntityFactory(MBInterface *mdb)
: mDensePageGroup(sizeof(void*), 0)
{
assert(NULL != mdb);
@@ -427,10 +385,10 @@
// need to make a new adjacency list first
adj_list_ptr = new MBAdjacencyVector();
result = mDensePageGroup.set_data(from_ent, &adj_list_ptr);
-
+
if (MB_SUCCESS != result) return result;
}
-
+
// get an iterator to the right spot in this sorted vector
MBAdjacencyVector::iterator adj_iter;
if (!adj_list_ptr->empty())
@@ -441,19 +399,10 @@
if ( adj_iter == adj_list_ptr->end() || to_ent != *adj_iter )
{
adj_list_ptr->insert(adj_iter, to_ent);
-#ifdef MOAB_WITH_REFCOUNT
- if (TYPE_FROM_HANDLE(from_ent) > TYPE_FROM_HANDLE(to_ent))
- increment_reference_count( to_ent );
-#endif
}
}
- else {
+ else
adj_list_ptr->push_back(to_ent);
-#ifdef MOAB_WITH_REFCOUNT
- if (TYPE_FROM_HANDLE(from_ent) > TYPE_FROM_HANDLE(to_ent))
- increment_reference_count( to_ent );
-#endif
- }
// if both_ways is true, recursively call this function
if (true == both_ways && to_type != MBVERTEX)
@@ -464,8 +413,7 @@
//! remove an adjacency from from the base_entity.
MBErrorCode AEntityFactory::remove_adjacency(MBEntityHandle base_entity,
- MBEntityHandle adj_to_remove,
- bool update_reference_count)
+ MBEntityHandle adj_to_remove)
{
MBErrorCode result;
@@ -487,30 +435,20 @@
// remove the specified entity from the adjacency list and truncate
// the list to the new length
- std::vector<MBEntityHandle>::iterator iter
- = std::lower_bound( adj_list->begin(), adj_list->end(), adj_to_remove );
- if (iter == adj_list->end() || *iter != adj_to_remove)
- return MB_FAILURE;
+ adj_list->erase(std::remove(adj_list->begin(), adj_list->end(), adj_to_remove),
+ adj_list->end());
- adj_list->erase( iter );
-#ifdef MOAB_WITH_REFCOUNT
- if (update_reference_count &&
- TYPE_FROM_HANDLE(base_entity) > TYPE_FROM_HANDLE(adj_to_remove))
- decrement_reference_count( adj_to_remove );
-#endif
-
// reset the adjacency data list
//result = thisMB->tag_set_data(adj_tag, base_entity, &adj_list);
//if (result != MB_SUCCESS)
//return result;
- return MB_SUCCESS;
+ return result;
}
//! remove all adjacencies from from the base_entity.
MBErrorCode AEntityFactory::remove_all_adjacencies(MBEntityHandle base_entity,
- const bool delete_adj_list,
- bool update_reference_counts)
+ const bool delete_adj_list)
{
MBErrorCode result;
@@ -524,7 +462,7 @@
if (MB_SUCCESS != result && MB_MULTIPLE_ENTITIES_FOUND != result) continue;
for (MBRange::iterator rit = ents.begin(); rit != ents.end(); rit++) {
if (explicitly_adjacent(*rit, base_entity))
- remove_adjacency(*rit, base_entity, update_reference_counts);
+ remove_adjacency(*rit, base_entity);
}
}
Modified: MOAB/trunk/AEntityFactory.hpp
===================================================================
--- MOAB/trunk/AEntityFactory.hpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/AEntityFactory.hpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -26,15 +26,13 @@
typedef std::vector<MBEntityHandle> MBAdjacencyVector;
-class MBCore;
-
//! class AEntityFactory
class AEntityFactory
{
public:
//! require an MBInterface object in order to access tags on that interface
- AEntityFactory(MBCore *mdb);
+ AEntityFactory(MBInterface *mdb);
//! destructor
~AEntityFactory();
@@ -49,13 +47,11 @@
//! remove an adjacency from from the base_entity.
MBErrorCode remove_adjacency(MBEntityHandle base_entity,
- MBEntityHandle adjacency_to_remove,
- bool update_reference_count = true);
+ MBEntityHandle adjacency_to_remove);
//! remove all adjacencies from from the base_entity.
MBErrorCode remove_all_adjacencies(MBEntityHandle base_entity,
- const bool delete_adj_list = false,
- bool update_reference_counts = true);
+ const bool delete_adj_list = false);
//! get the elements contained by source_entity, of
//! type target_type, passing back in target_entities; if create_if_missing
@@ -144,23 +140,13 @@
unsigned long& total_entity_storage,
unsigned long& total_amortized_storage );
-#ifdef MOAB_WITH_REFCOUNT
- MBErrorCode decrement_reference_count( const MBEntityHandle* arr, size_t len );
- MBErrorCode increment_reference_count( const MBEntityHandle* arr, size_t len );
- MBErrorCode decrement_reference_count( MBEntityHandle ent )
- { return decrement_reference_count( &ent, 1 ); }
- MBErrorCode increment_reference_count( MBEntityHandle ent )
- { return increment_reference_count( &ent, 1 ); }
- MBErrorCode decrement_referenced_entities( MBEntityHandle h );
- MBErrorCode increment_referenced_entities( MBEntityHandle h );
-#endif
private:
//! private constructor to prevent the construction of a default one
AEntityFactory();
//! interface associated with this tool
- MBCore *thisMB;
+ MBInterface *thisMB;
//! adjacencies collection
DensePageGroup mDensePageGroup;
@@ -217,7 +203,7 @@
inline MBErrorCode AEntityFactory::notify_delete_entity(MBEntityHandle entity)
{
// remove any references to this entity from other entities
- return remove_all_adjacencies(entity, true, false);
+ return remove_all_adjacencies(entity, true);
}
Modified: MOAB/trunk/EntitySequence.cpp
===================================================================
--- MOAB/trunk/EntitySequence.cpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/EntitySequence.cpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -37,9 +37,6 @@
MBEntitySequence::MBEntitySequence(EntitySequenceManager* seq_manager,
MBEntityHandle start_handle, MBEntityID num_entities )
: mSequenceManager(seq_manager)
-#ifdef MOAB_WTIH_REFCOUNT
- , mRefCount( num_entities, 0 )
-#endif
{
assert(MB_START_ID <= ID_FROM_HANDLE(start_handle));
assert(TYPE_FROM_HANDLE(start_handle) < MBMAXTYPE);
@@ -78,13 +75,7 @@
mCoords[1] = new double[num_entities];
mCoords[2] = new double[num_entities];
-#ifdef MOAB_WITH_REFCOUNT
- mRefCount.clear();
- mRefCount.resize( num_entities, all_handles_used ? 1 : 0 );
-#else
mFreeEntities.clear();
-#endif
-
if(all_handles_used)
{
mNumEntities = num_entities;
@@ -93,9 +84,7 @@
else
{
seq_manager->notify_not_full(this);
-#ifndef MOAB_WITH_REFCOUNT
mFreeEntities.resize(mNumAllocated, true);
-#endif
mNumEntities = 0;
mFirstFreeIndex = 0;
for(MBEntityID i=0; i<num_entities; i++)
@@ -122,11 +111,7 @@
return 0;
MBEntityHandle new_handle = mStartEntityHandle + mFirstFreeIndex;
-#ifdef MOAB_WITH_REFCOUNT
- mRefCount[mFirstFreeIndex] = 1;
-#else
mFreeEntities[mFirstFreeIndex] = false;
-#endif
mFirstFreeIndex = reinterpret_cast<MBEntityID&>(mCoords[0][mFirstFreeIndex]);
@@ -134,10 +119,8 @@
if(mNumEntities == mNumAllocated) {
mSequenceManager->notify_full(this);
-#ifndef MOAB_WITH_REFCOUNT
std::vector<bool> empty;
mFreeEntities.swap(empty);
-#endif
}
if( mLastDeletedIndex == (MBEntityID)( new_handle - mStartEntityHandle ))
@@ -152,21 +135,12 @@
if(!is_valid_entity(handle))
return;
-#ifdef MOAB_WITH_REFCOUNT
- if (get_reference_count(handle) != 1) // only referenced by this sequence
- return;
- decrement_reference_count(handle);
-#endif
-
if(mNumEntities == mNumAllocated) {
mSequenceManager->notify_not_full(this);
-#ifndef MOAB_WITH_REFCOUNT
mFreeEntities.resize( mNumAllocated, false );
-#endif
}
-#ifndef MOAB_WITH_REFCOUNT
+
mFreeEntities[handle - mStartEntityHandle] = true;
-#endif
MBEntityID prev_free_handle = -1;
const MBEntityID handle_index = handle - mStartEntityHandle;
@@ -232,22 +206,13 @@
unsigned long& allocated) const
{
unsigned long per_ent = get_memory_use((MBEntityHandle)0);
- allocated = sizeof(*this) + per_ent*number_allocated();
-#ifdef MOAB_WITH_REFCOUNT
- allocated += mRefCount.capacity() * sizeof(int);
-#else
- allocated += mFreeEntities.capacity()/8;
-#endif
+ allocated = sizeof(*this) + mFreeEntities.capacity()/8 + per_ent*number_allocated();
used = per_ent * number_entities();
}
unsigned long VertexEntitySequence::get_memory_use( MBEntityHandle ) const
{
-#ifdef MOAB_WITH_REFCOUNT
- return 3 * sizeof(double) + sizeof(unsigned);
-#else
return 3 * sizeof(double);
-#endif
}
MBEntityID ElementEntitySequence::get_next_free_index( MBEntityID prev_free_index ) const
@@ -281,13 +246,7 @@
seq_manager->entity_sequence_created(this);
-#ifdef MOAB_WITH_REFCOUNT
- mRefCount.clear();
- mRefCount.resize( num_entities, all_handles_used ? 1 : 0 );
-#else
mFreeEntities.clear();
-#endif
-
if(all_handles_used)
{
mNumEntities = num_entities;
@@ -296,9 +255,7 @@
else
{
seq_manager->notify_not_full(this);
-#ifndef MOAB_WITH_REFCOUNT
mFreeEntities.resize( mNumAllocated, true );
-#endif
mNumEntities = 0;
mFirstFreeIndex = 0;
if (nodes_per_element)
@@ -326,11 +283,7 @@
if(mFirstFreeIndex == -1)
return 0;
-#ifdef MOAB_WITH_REFCOUNT
- mRefCount[mFirstFreeIndex] = 1;
-#else
mFreeEntities[mFirstFreeIndex] = false;
-#endif
MBEntityHandle new_handle = mStartEntityHandle + mFirstFreeIndex;
mFirstFreeIndex = reinterpret_cast<MBEntityID&>(mElements[mFirstFreeIndex*mNodesPerElement]);
@@ -340,9 +293,7 @@
if(mNumEntities == mNumAllocated) {
mSequenceManager->notify_full(this);
std::vector<bool> empty;
-#ifndef MOAB_WITH_REFCOUNT
mFreeEntities.swap(empty);
-#endif
}
if( mLastDeletedIndex == (MBEntityID)( new_handle - mStartEntityHandle ))
@@ -356,22 +307,12 @@
if(!is_valid_entity(handle))
return;
-#ifdef MOAB_WITH_REFCOUNT
- if (get_reference_count(handle) != 1)
- return;
- decrement_reference_count(handle);
-#endif
-
if(mNumEntities == mNumAllocated) {
mSequenceManager->notify_not_full(this);
-#ifndef MOAB_WITH_REFCOUNT
mFreeEntities.resize( mNumAllocated, false );
-#endif
}
-#ifndef MOAB_WITH_REFCOUNT
mFreeEntities[handle-mStartEntityHandle] = true;
-#endif
MBEntityID prev_free_index = -1;
const MBEntityID handle_index = handle - mStartEntityHandle;
@@ -438,7 +379,7 @@
assert(get_end_handle() >= split_location);
// make a new sequence
- const bool all_used = (mNumEntities == mNumAllocated);
+ const bool all_used = mFreeEntities.empty();
ElementEntitySequence* seq = new ElementEntitySequence( mSequenceManager, split_location,
get_end_handle() - split_location + 1 , mNodesPerElement, all_used);
new_sequence = seq;
@@ -464,15 +405,6 @@
assert( seq->mNumEntities == seq->mNumAllocated );
return MB_SUCCESS;
}
-
-#ifdef MOAB_WITH_REFCOUNT
- const MBEntityHandle count = split_location - get_start_handle();
- seq->mRefCount = mRefCount;
- mRefCount.resize( count );
- seq->mRefCount.erase( seq->mRefCount.begin(), seq->mRefCount.begin() + count );
- std::vector<unsigned>(mRefCount).swap(mRefCount);
- std::vector<unsigned>(seq->mRefCount).swap(seq->mRefCount);
-#else
//copy free handles over too
std::copy(mFreeEntities.begin()+(split_location-mStartEntityHandle),
@@ -481,26 +413,21 @@
// shrink capacity to what we need
mFreeEntities.resize(mNumAllocated);
std::vector<bool>(mFreeEntities).swap(mFreeEntities);
-#endif
+
// need to recompute : mNumEntities, mFirstFreeIndex for both sequences
mNumEntities = 0;
mFirstFreeIndex = -1;
-#ifdef MOAB_WITH_REFCOUNT
- std::vector<unsigned>::reverse_iterator iter = mRefCount.rbegin();
- std::vector<unsigned>::reverse_iterator end_iter = mRefCount.rend();
-#else
std::vector<bool>::reverse_iterator iter = mFreeEntities.rbegin();
std::vector<bool>::reverse_iterator end_iter = mFreeEntities.rend();
-#endif
- MBEntityID index = mNumAllocated - 1;
+ MBEntityID index = mFreeEntities.size() - 1;
MBEntityID last_index = -1;
for(; iter != end_iter; )
{
- if(*iter)
+ if(*iter == true)
{
reinterpret_cast<MBEntityID&>(mElements[index*mNodesPerElement]) = last_index;
last_index = index;
@@ -517,10 +444,8 @@
if(mNumEntities == mNumAllocated) {
mSequenceManager->notify_full(this);
-#ifndef MOAB_WITH_REFCOUNT
std::vector<bool> empty;
mFreeEntities.swap( empty );
-#endif
}
else
mSequenceManager->notify_not_full(this);
@@ -529,20 +454,14 @@
seq->mNumEntities = 0;
seq->mFirstFreeIndex = -1;
-#ifdef MOAB_WITH_REFCOUNT
- iter = seq->mRefCount.rbegin();
- end_iter = seq->mRefCount.rend();
- index = seq->mRefCount.size() - 1;
-#else
iter = seq->mFreeEntities.rbegin();
end_iter = seq->mFreeEntities.rend();
index = seq->mFreeEntities.size() - 1;
-#endif
last_index = -1;
for(; iter != end_iter; )
{
- if(*iter)
+ if(*iter == true)
{
reinterpret_cast<MBEntityID&>(seq->mElements[index*mNodesPerElement]) = last_index;
last_index = index;
@@ -559,10 +478,8 @@
if(seq->mNumEntities == seq->mNumAllocated) {
mSequenceManager->notify_full(seq);
-#ifndef MOAB_WITH_REFCOUNT
std::vector<bool> empty;
seq->mFreeEntities.swap( empty );
-#endif
}
else
mSequenceManager->notify_not_full(seq);
@@ -573,15 +490,10 @@
MBErrorCode ElementEntitySequence::convert_realloc(bool& mid_edge_nodes,
- bool& mid_face_nodes, bool& mid_volume_nodes, MBCore* MB
-#ifndef MOAB_WITH_REFCOUNT
- , MBTag delete_mark_bit
-#endif
- )
+ bool& mid_face_nodes, bool& mid_volume_nodes, MBCore* MB,
+ MBTag delete_mark_bit )
{
-#ifdef MOAB_WITH_REFCOUNT
- MBRange dead_nodes;
-#endif
+
MBEntityType this_type = get_type();
// figure out how many nodes per element we'll end up with
@@ -634,22 +546,13 @@
old_end_handle = mElements + mNodesPerElement*mNumAllocated;
old_iter = mElements + MBCN::VerticesPerEntity(this_type);
-#ifndef MOAB_WITH_REFCOUNT
std::set<MBEntityHandle> nodes_processed;
-#endif
for(; old_iter < old_end_handle; )
{
//tag each node-to-delete with parent element entity handle and number
//of elements it is found on
for(int i=0; i<number_to_delete; i++)
{
-#ifdef MOAB_WITH_REFCOUNT
- if (old_iter[i]) {
- MB->decrement_reference_count( old_iter[i] );
- if (MB->get_reference_count( old_iter[i] ) == 1)
- dead_nodes.insert( old_iter[i] );
- }
-#else
//see if node has been processed yet
if( old_iter[i] && nodes_processed.insert(old_iter[i]).second )
{
@@ -662,7 +565,6 @@
MB->tag_set_data(delete_mark_bit, &(old_iter[i]), 1, &bit);
}
}
-#endif
}
old_iter += mNodesPerElement;
}
@@ -696,22 +598,13 @@
if(has_mid_edge_nodes())
old_iter+=MBCN::mConnectivityMap[this_type][0].num_sub_elements;
-#ifndef MOAB_WITH_REFCOUNT
std::set<MBEntityHandle> nodes_processed;
-#endif
for(; old_iter < old_end_handle; )
{
//tag each node-to-delete with parent element entity handle and number
//of elements it is found on
for(int i=0; i<number_to_delete; i++)
{
-#ifdef MOAB_WITH_REFCOUNT
- if (old_iter[i]) {
- MB->decrement_reference_count( old_iter[i] );
- if (MB->get_reference_count( old_iter[i] ) == 1)
- dead_nodes.insert( old_iter[i] );
- }
-#else
//see if node has been processed yet
if( old_iter[i] && nodes_processed.insert(old_iter[i]).second )
{
@@ -724,7 +617,6 @@
MB->tag_set_data(delete_mark_bit, &(old_iter[i]), 1, &bit);
}
}
-#endif
}
old_iter += mNodesPerElement;
}
@@ -761,20 +653,12 @@
for(; old_iter < old_end_handle; )
{
-#ifdef MOAB_WITH_REFCOUNT
- if (*old_iter) {
- MB->sequence_manager()->decrement_reference_count( *old_iter );
- if (MB->get_reference_count( *old_iter ) == 1)
- dead_nodes.insert( *old_iter );
- }
-#else
if( *old_iter != 0 && tag_for_deletion( old_iter - mElements, MB ) )
{
//tag node as deletable
unsigned char bit = 0x1;
MB->tag_set_data(delete_mark_bit, &(*old_iter), 1, &bit);
}
-#endif
old_iter += mNodesPerElement;
}
@@ -793,12 +677,8 @@
mElements = new_array;
mNodesPerElement = new_nodes_per_element;
-
-#ifdef MOAB_WITH_REFCOUNT
- return MB->delete_entities( dead_nodes );
-#else
+
return MB_SUCCESS;
-#endif
}
bool ElementEntitySequence::has_mid_edge_nodes() const
@@ -917,37 +797,11 @@
unsigned long& allocated) const
{
unsigned long per_ent = get_memory_use((MBEntityHandle)0);
- allocated = sizeof(*this) + per_ent*number_allocated();
-#ifdef MOAB_WITH_REFCOUNT
- allocated += mRefCount.capacity() * sizeof(unsigned);
-#else
- allocated += mFreeEntities.capacity()/8;
-#endif
+ allocated = sizeof(*this) + mFreeEntities.capacity()/8 + per_ent*number_allocated();
used = per_ent * number_entities();
}
unsigned long ElementEntitySequence::get_memory_use( MBEntityHandle ) const
{
-#ifdef MOAB_WITH_REFCOUNT
- return sizeof(MBEntityHandle) * nodes_per_element() + sizeof(unsigned);
-#else
return sizeof(MBEntityHandle) * nodes_per_element();
-#endif
}
-
-#ifdef MOAB_WITH_REFCOUNT
-void ElementEntitySequence::decrement_all_referenced_entities( MBEntityHandle entity, AEntityFactory* f)
-{
- const MBEntityHandle* conn;
- int len;
- if (MB_SUCCESS == get_connectivity( entity, conn, len ))
- f->decrement_reference_count( conn, len );
-}
-void ElementEntitySequence::increment_all_referenced_entities( MBEntityHandle entity, AEntityFactory* f)
-{
- const MBEntityHandle* conn;
- int len;
- if (MB_SUCCESS == get_connectivity( entity, conn, len ))
- f->increment_reference_count( conn, len );
-}
-#endif
Modified: MOAB/trunk/EntitySequence.hpp
===================================================================
--- MOAB/trunk/EntitySequence.hpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/EntitySequence.hpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -42,7 +42,6 @@
class EntitySequenceManager;
class MBCore;
-class AEntityFactory;
class MBEntitySequence
{
@@ -102,18 +101,6 @@
unsigned long& allocated ) const = 0;
virtual unsigned long get_memory_use( MBEntityHandle handle ) const = 0;
-#ifdef MOAB_WITH_REFCOUNT
- unsigned increment_reference_count( MBEntityHandle entity )
- { return ++mRefCount[entity-get_start_handle()]; }
- unsigned decrement_reference_count( MBEntityHandle entity )
- { return --mRefCount[entity-get_start_handle()]; }
- unsigned get_reference_count( MBEntityHandle entity) const
- { return mRefCount[entity-get_start_handle()]; }
-
- virtual void decrement_all_referenced_entities( MBEntityHandle entity, AEntityFactory* ) = 0;
- virtual void increment_all_referenced_entities( MBEntityHandle entity, AEntityFactory* ) = 0;
-#endif
-
protected:
EntitySequenceManager* mSequenceManager;
@@ -135,11 +122,8 @@
MBEntityID mLastDeletedIndex;
//! a list of whether entities are free or not
-#ifdef MOAB_WITH_REFCOUNT
- std::vector<unsigned> mRefCount;
-#else
std::vector<bool> mFreeEntities;
-#endif
+
};
@@ -178,11 +162,6 @@
virtual void get_memory_use( unsigned long& used, unsigned long& allocated ) const;
virtual unsigned long get_memory_use( MBEntityHandle handle ) const;
-
-#ifdef MOAB_WITH_REFCOUNT
- virtual void decrement_all_referenced_entities( MBEntityHandle , AEntityFactory* ) {}
- virtual void increment_all_referenced_entities( MBEntityHandle , AEntityFactory* ) {}
-#endif
private:
// coordinate arrays x,y,z
@@ -228,11 +207,7 @@
// reallocated the sequence to hold extra/less nodes, pass in what you want, and will return whether it needed
// reallocate space for those nodes
virtual MBErrorCode convert_realloc(bool& mid_edge_nodes, bool& mid_face_nodes, bool& mid_volume_nodes,
- MBCore* MB
-#ifndef MOAB_WITH_REFCOUNT
- , MBTag bit_delete_mark
-#endif
- );
+ MBCore* MB, MBTag bit_delete_mark );
virtual bool has_mid_edge_nodes() const;
virtual bool has_mid_face_nodes() const;
@@ -241,10 +216,6 @@
virtual void get_memory_use( unsigned long& used, unsigned long& allocated ) const;
virtual unsigned long get_memory_use( MBEntityHandle handle ) const;
-#ifdef MOAB_WITH_REFCOUNT
- virtual void decrement_all_referenced_entities( MBEntityHandle entity, AEntityFactory* f);
- virtual void increment_all_referenced_entities( MBEntityHandle entity, AEntityFactory* f);
-#endif
protected:
unsigned short mNodesPerElement;
@@ -261,11 +232,7 @@
inline bool MBEntitySequence::is_valid_entity(MBEntityHandle entity) const
{
-#ifdef MOAB_WITH_REFCOUNT
- return 0 != get_reference_count(entity);
-#else
return mFreeEntities.empty() || !mFreeEntities[entity-mStartEntityHandle];
-#endif
}
Modified: MOAB/trunk/EntitySequenceManager.hpp
===================================================================
--- MOAB/trunk/EntitySequenceManager.hpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/EntitySequenceManager.hpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -43,9 +43,9 @@
#include "MBForward.hpp"
#include "MBProcConfig.hpp"
-#include "EntitySequence.hpp"
#include <map>
+class MBEntitySequence;
class HomCoord;
//! class for managing entity sequences
@@ -137,12 +137,6 @@
unsigned long& total_entity_storage,
unsigned long& total_amortized_storage ) const;
-#ifdef MOAB_WITH_REFCOUNT
- inline unsigned increment_reference_count( MBEntityHandle handle );
- inline unsigned decrement_reference_count( MBEntityHandle handle );
- inline unsigned get_reference_count( MBEntityHandle handle ) const;
-#endif
-
private:
//! creates an entity sequence with a start handle and number of entities
@@ -180,24 +174,6 @@
const MBProcConfig procInfo;
};
-#ifdef MOAB_WITH_REFCOUNT
-unsigned EntitySequenceManager::increment_reference_count( MBEntityHandle handle )
-{
- MBEntitySequence* seq;
- return MB_SUCCESS == find( handle, seq ) ? seq->increment_reference_count(handle) : 0;
-}
-unsigned EntitySequenceManager::decrement_reference_count( MBEntityHandle handle )
-{
- MBEntitySequence* seq;
- return MB_SUCCESS == find( handle, seq ) ? seq->decrement_reference_count(handle) : 0;
-}
-unsigned EntitySequenceManager::get_reference_count( MBEntityHandle handle ) const
-{
- MBEntitySequence* seq;
- return MB_SUCCESS == find( handle, seq ) ? seq->get_reference_count(handle) : 0;
-}
#endif
-#endif
-
Modified: MOAB/trunk/HigherOrderFactory.cpp
===================================================================
--- MOAB/trunk/HigherOrderFactory.cpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/HigherOrderFactory.cpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -234,10 +234,6 @@
if(this_type == MBTRI || this_type == MBQUAD)
temp_mid_volume = false;
-#ifdef MOAB_WITH_REFCOUNT
- seq->convert_realloc(temp_mid_edge, temp_mid_face, temp_mid_volume, mMB);
-
-#else
MBTag deletable_nodes;
mMB->tag_create("", 1, MB_TAG_BIT, deletable_nodes, NULL);
@@ -266,7 +262,6 @@
}
mMB->tag_delete(deletable_nodes);
-#endif
// create mid edge nodes if necessary
if(temp_mid_edge)
@@ -332,9 +327,6 @@
// create a new vertex at the centroid
mMB->create_vertex(sum_coords, element[new_node_index]);
-#ifdef MOAB_WITH_REFCOUNT
- mMB->increment_reference_count( element[new_node_index] );
-#endif
if(mHONodeAddedRemoved)
mHONodeAddedRemoved->node_added(element[new_node_index], curr_handle);
@@ -421,9 +413,6 @@
mMB->create_vertex(sum_coords, element[i+num_edges+num_vertices]);
}
-#ifdef MOAB_WITH_REFCOUNT
- mMB->increment_reference_count( element[i+num_edges+num_vertices] );
-#endif
if(mHONodeAddedRemoved)
mHONodeAddedRemoved->node_added(element[i+num_edges+num_vertices], curr_handle);
@@ -509,9 +498,6 @@
mMB->create_vertex(sum_coords, element[i+num_vertices]);
}
-#ifdef MOAB_WITH_REFCOUNT
- mMB->increment_reference_count( element[i+num_vertices] );
-#endif
if(mHONodeAddedRemoved)
mHONodeAddedRemoved->node_added(element[i+num_vertices], curr_handle);
Modified: MOAB/trunk/MBCore.cpp
===================================================================
--- MOAB/trunk/MBCore.cpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/MBCore.cpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -950,23 +950,13 @@
aEntityFactory->notify_change_connectivity(
entity_handle, old_conn, connect, num_connect);
-#ifdef MOAB_WITH_REFCOUNT
- decrement_reference_count( old_conn, num_connect );
-#endif
status = static_cast<ElementEntitySequence*>(seq)->set_connectivity(entity_handle,
connect, num_connect);
- if (status != MB_SUCCESS) {
+ if (status != MB_SUCCESS)
aEntityFactory->notify_change_connectivity(
entity_handle, connect, old_conn, num_connect);
-#ifdef MOAB_WITH_REFCOUNT
- increment_reference_count( old_conn, num_connect );
- }
- else {
- increment_reference_count( connect, num_connect );
-#endif
- }
-
+
return status;
}
@@ -1397,86 +1387,22 @@
const int num_entities,
const void *tag_data)
{
- MBErrorCode rval;
-#ifdef MOAB_WITH_REFCOUNT
- std::vector<MBEntityHandle> old_data;
- std::vector<MBEntityHandle> unique_handles;
- const TagInfo* tag_info = tagServer->get_tag_info( tag_handle );
- if(!tag_info)
- return MB_TAG_NOT_FOUND;
- int count;
-#endif
+ if (NULL == entity_handles && 0 == num_entities)
+ return tagServer->set_mesh_data(tag_handle, tag_data);
- if (NULL == entity_handles && 0 == num_entities) {
-#ifdef MOAB_WITH_REFCOUNT
- if (tag_info->get_data_type() == MB_TYPE_HANDLE) {
- count = tag_info->get_size() / sizeof(MBEntityHandle);
- old_data.resize( count );
- rval = tagServer->get_mesh_data( tag_handle, &old_data[0] );
- if (MB_SUCCESS == rval) {
- rval = decrement_reference_count( &old_data[0], count );
- if (MB_SUCCESS != rval)
- return rval;
- }
- else
- old_data.clear();
- }
-#endif
- rval = tagServer->set_mesh_data(tag_handle, tag_data);
- }
- else {
//verify handles
- MBEntitySequence* seq;
- const MBEntityHandle* iter;
- const MBEntityHandle* end = entity_handles + num_entities;
- for(iter = entity_handles; iter != end; ++iter)
- {
- if (TYPE_FROM_HANDLE(*iter) == MBENTITYSET) continue;
-
- else if(sequenceManager->find(*iter, seq) != MB_SUCCESS)
- return MB_ENTITY_NOT_FOUND;
- }
+ MBEntitySequence* seq;
+ const MBEntityHandle* iter;
+ const MBEntityHandle* end = entity_handles + num_entities;
+ for(iter = entity_handles; iter != end; ++iter)
+ {
+ if (TYPE_FROM_HANDLE(*iter) == MBENTITYSET) continue;
-#ifdef MOAB_WITH_REFCOUNT
- if (tag_info->get_data_type() == MB_TYPE_HANDLE) {
- unique_handles.resize( num_entities );
- std::copy( entity_handles, entity_handles+num_entities, unique_handles.begin() );
- std::sort( unique_handles.begin(), unique_handles.end() );
- unique_handles.erase( std::unique( unique_handles.begin(), unique_handles.end() ), unique_handles.end() );
-
- count = tag_info->get_size() * unique_handles.size() / sizeof(MBEntityHandle);
- old_data.resize( count );
- rval = tagServer->get_mesh_data( tag_handle, &old_data[0] );
- if (MB_SUCCESS == rval) {
- rval = decrement_reference_count( &old_data[0], count );
- if (MB_SUCCESS != rval)
- return rval;
- }
- else
- old_data.clear();
- }
-#endif
-
- rval = tagServer->set_data(tag_handle, entity_handles, num_entities, tag_data);
+ else if(sequenceManager->find(*iter, seq) != MB_SUCCESS)
+ return MB_ENTITY_NOT_FOUND;
}
-#ifdef MOAB_WITH_REFCOUNT
- if (tag_info->get_data_type() == MB_TYPE_HANDLE) {
- if (MB_SUCCESS == rval) {
- if (unique_handles.size()) {
- tag_server()->get_data( tag_handle, &unique_handles[0], unique_handles.size(), &old_data[0] );
- rval = increment_reference_count( &old_data[0], count );
- }
- else {
- rval = increment_reference_count( (const MBEntityHandle*)tag_data, count );
- }
- }
- else if (!old_data.empty())
- increment_reference_count( &old_data[0], count );
- }
-#endif
-
- return rval;
+ return tagServer->set_data(tag_handle, entity_handles, num_entities, tag_data);
}
//! set the data for given EntityHandles and MBTag
@@ -1497,39 +1423,7 @@
return result;
}
-#ifdef MOAB_WITH_REFCOUNT
- std::vector<MBEntityHandle> old_data;
- const TagInfo* tag_info = tagServer->get_tag_info( tag_handle );
- if(!tag_info)
- return MB_TAG_NOT_FOUND;
- int count;
- if (tag_info->get_data_type() == MB_TYPE_HANDLE) {
- count = tag_info->get_size() * entity_handles.size() / sizeof(MBEntityHandle);
- old_data.resize( count );
- result = tagServer->get_data( tag_handle, entity_handles, &old_data[0] );
- if (MB_SUCCESS != result)
- old_data.clear();
- else {
- result = decrement_reference_count( &old_data[0], count );
- if (MB_SUCCESS != result)
- return result;
- }
- }
-#endif
-
- result = tagServer->set_data(tag_handle, entity_handles, tag_data);
-
-#ifdef MOAB_WITH_REFCOUNT
- if (tag_info->get_data_type() == MB_TYPE_HANDLE) {
- if (MB_SUCCESS == result)
- result = increment_reference_count( (const MBEntityHandle*)tag_data, count );
- else if (!old_data.empty())
- increment_reference_count( &old_data[0], count );
- }
-#endif
-
- return result;
-
+ return tagServer->set_data(tag_handle, entity_handles, tag_data);
}
//! adds a sparse tag for this specific EntityHandle/tag_name combination
@@ -1551,17 +1445,6 @@
const void* def_val,
bool use_existing )
{
-#ifdef MOAB_WITH_REFCOUNT
- // don't allow a non-zero default value for handle-type tags
- // if reference counting is enabled.
- if (data == MB_TYPE_HANDLE && def_val) {
- const MBEntityHandle* handles = (const MBEntityHandle*)def_val;
- for (size_t i = 0; i < size / sizeof(MBEntityHandle); ++i)
- if (handles[i])
- return MB_FAILURE;
- }
-#endif
-
MBErrorCode rval = tagServer->add_tag( name, size, storage, data, handle, def_val );
// If it is okay to use an existing tag of the same name, check that it
@@ -1601,32 +1484,11 @@
return MB_FAILURE;
MBErrorCode status = MB_SUCCESS, temp_status;
-#ifdef MOAB_WITH_REFCOUNT
- std::vector<MBEntityHandle> old_data;
- const TagInfo* tag_info = tagServer->get_tag_info( tag_handle );
- if(!tag_info)
- return MB_TAG_NOT_FOUND;
- if (tag_info->get_data_type() == MB_TYPE_HANDLE)
- old_data.resize( tag_info->get_size()/sizeof(MBEntityHandle) );
-#endif
-
for (int i = 0; i < num_handles; i++) {
- if (0 == entity_handles[i]) {
-#ifdef MOAB_WITH_REFCOUNT
- if (tag_info->get_data_type() == MB_TYPE_HANDLE &&
- MB_SUCCESS == tagServer->get_mesh_data( tag_handle, &old_data[0] ))
- decrement_reference_count( &old_data[0], old_data.size() );
-#endif
+ if (0 == entity_handles[i])
temp_status = tagServer->remove_mesh_data(tag_handle);
- }
- else {
-#ifdef MOAB_WITH_REFCOUNT
- if (tag_info->get_data_type() == MB_TYPE_HANDLE &&
- MB_SUCCESS == tagServer->get_data( tag_handle, entity_handles+i, 1, &old_data[0] ))
- decrement_reference_count( &old_data[0], old_data.size() );
-#endif
+ else
temp_status = tagServer->remove_data(tag_handle, entity_handles[i]);
- }
if (temp_status != MB_SUCCESS) status = temp_status;
}
@@ -1640,22 +1502,8 @@
if (PROP_FROM_TAG_HANDLE(tag_handle) == MB_TAG_DENSE)
return MB_FAILURE;
-#ifdef MOAB_WITH_REFCOUNT
- std::vector<MBEntityHandle> old_data;
- const TagInfo* tag_info = tagServer->get_tag_info( tag_handle );
- if(!tag_info)
- return MB_TAG_NOT_FOUND;
- if (tag_info->get_data_type() == MB_TYPE_HANDLE)
- old_data.resize( tag_info->get_size()/sizeof(MBEntityHandle) );
-#endif
-
MBErrorCode status = MB_SUCCESS, temp_status;
for (MBRange::const_iterator it = entity_handles.begin(); it != entity_handles.end(); it++) {
-#ifdef MOAB_WITH_REFCOUNT
- if (tag_info->get_data_type() == MB_TYPE_HANDLE &&
- MB_SUCCESS == tagServer->get_data( tag_handle, &*it, 1, &old_data[0] ))
- decrement_reference_count( &old_data[0], old_data.size() );
-#endif
temp_status = tagServer->remove_data(tag_handle, *it);
if (temp_status != MB_SUCCESS) status = temp_status;
}
@@ -1666,21 +1514,6 @@
//! removes the tag from MB
MBErrorCode MBCore::tag_delete(MBTag tag_handle)
{
-#ifdef MOAB_WITH_REFCOUNT
- const TagInfo* tag_info = tagServer->get_tag_info( tag_handle );
- if(!tag_info)
- return MB_TAG_NOT_FOUND;
- if (tag_info->get_data_type() == MB_TYPE_HANDLE) {
- std::vector<MBEntityHandle> tag_data;
- for (MBEntityType t = MBVERTEX; t <= MBENTITYSET; ++t) {
- MBRange entities;
- tagServer->get_entities( tag_handle, t, entities );
- tag_data.resize( entities.size() );
- tagServer->get_data( tag_handle, entities, &tag_data[0] );
- decrement_reference_count( &tag_data[0], tag_data.size() );
- }
- }
-#endif
return tag_server()->remove_tag(tag_handle);
}
@@ -1916,82 +1749,50 @@
}
-MBErrorCode MBCore::delete_entity( MBEntityHandle handle )
-{
- MBErrorCode result;
-
- // tell AEntityFactory that this element is going away
- result = aEntityFactory->notify_delete_entity(handle);
- if (MB_SUCCESS != result)
- return result;
-
- // reset and/or clean out data associated with this entity handle
- result = tagServer->reset_data(handle);
- if (MB_SUCCESS != result)
- return result;
-
- if (TYPE_FROM_HANDLE(handle) == MBENTITYSET) {
- if (MBMeshSet* ptr = get_mesh_set( sequence_manager(), handle )) {
- int j, count;
- const MBEntityHandle* rel;
- ptr->clear( handle, a_entity_factory() );
- rel = ptr->get_parents( count );
- for (j = 0; j < count; ++j)
- remove_child_meshset( rel[j], handle );
- rel = ptr->get_children( count );
- for (j = 0; j < count; ++j)
- remove_parent_meshset( rel[j],handle );
- }
- }
-
- // now delete the entity
- result = sequence_manager()->delete_entity(handle);
- if (MB_SUCCESS != result)
- return result;
-
- return MB_SUCCESS;
-}
-
//! deletes an entity vector
MBErrorCode MBCore::delete_entities(const MBEntityHandle *entities,
const int num_entities)
{
- // If reference counting is enabled, make sure all entities
- // are unreferenced, assuming all other entities in the list
- // are also deleted.
-#ifdef MOAB_WITH_REFCOUNT
- std::vector<MBTag> handle_tags;
- tag_server()->get_tags( MB_TYPE_HANDLE, handle_tags );
-
- int ii, jj;
- // before deleting each entity, decrement the reference count on
- // everything that entity references.
- for (ii = 0; ii < num_entities; ++ii)
- if (MB_SUCCESS != decrement_all_referenced_entities( entities[ii], handle_tags ))
- break;
- // make sure everything that is to be deleted has a reference count
- // of 1 (only referenced by the containing sequence).
- if (ii == num_entities)
- for (jj = 0; jj < num_entities; ++jj)
- if (get_reference_count( entities[jj] ) != 1)
- break;
- // if we can't delete the entities, but the reference counts back
- // to what they were before and return failure.
- if (ii < num_entities || jj < num_entities) {
- while (ii > 0)
- increment_all_referenced_entities( entities[--ii], handle_tags );
- return MB_FAILURE;
- }
-
-#endif
-
MBErrorCode result = MB_SUCCESS, temp_result;
+
for (int i = 0; i < num_entities; i++) {
- temp_result = delete_entity( entities[i] );
- if (MB_SUCCESS != temp_result)
+
+ // tell AEntityFactory that this element is going away
+ temp_result = aEntityFactory->notify_delete_entity(entities[i]);
+ if (MB_SUCCESS != temp_result) {
result = temp_result;
+ continue;
+ }
+
+ // reset and/or clean out data associated with this entity handle
+ temp_result = tagServer->reset_data(entities[i]);
+ if (MB_SUCCESS != temp_result) {
+ result = temp_result;
+ continue;
+ }
+
+ if (TYPE_FROM_HANDLE(entities[i]) == MBENTITYSET) {
+ if (MBMeshSet* ptr = get_mesh_set( sequence_manager(), entities[i] )) {
+ int j, count;
+ const MBEntityHandle* rel;
+ ptr->clear( entities[i], a_entity_factory() );
+ rel = ptr->get_parents( count );
+ for (j = 0; j < count; ++j)
+ remove_child_meshset( rel[j], entities[i] );
+ rel = ptr->get_children( count );
+ for (j = 0; j < count; ++j)
+ remove_parent_meshset( rel[j], entities[i] );
+ }
+ }
+
+ // now delete the entity
+ temp_result = sequence_manager()->delete_entity(entities[i]);
+ if (MB_SUCCESS != temp_result) {
+ result = temp_result;
+ continue;
+ }
}
-
+
return result;
}
@@ -1999,36 +1800,9 @@
//! deletes an entity range
MBErrorCode MBCore::delete_entities(const MBRange &range)
{
- // If reference counting is enabled, make sure all entities
- // are unreferenced, assuming all other entities in the list
- // are also deleted.
-#ifdef MOAB_WITH_REFCOUNT
- std::vector<MBTag> handle_tags;
- tag_server()->get_tags( MB_TYPE_HANDLE, handle_tags );
-
- MBRange::const_iterator ii, jj;
- // before deleting each entity, decrement the reference count on
- // everything that entity references.
- for (ii = range.begin(); ii != range.end(); ++ii)
- if (MB_SUCCESS != decrement_all_referenced_entities( *ii, handle_tags ))
- break;
- // make sure everything that is to be deleted has a reference count
- // of 1 (only referenced by the containing sequence).
- if (ii == range.end())
- for (jj = range.begin(); jj != range.end(); ++jj)
- if (get_reference_count( *jj ) != 1)
- break;
- // if we can't delete the entities, but the reference counts back
- // to what they were before and return failure.
- if (ii != range.end() || jj != range.end()) {
- while (ii != range.begin())
- increment_all_referenced_entities( *--ii, handle_tags );
- return MB_FAILURE;
- }
-#endif
MBErrorCode result = MB_SUCCESS, rval;
for (MBRange::iterator i = range.begin(); i != range.end(); ++i)
- if (MB_SUCCESS != (rval = delete_entity( *i )))
+ if (MB_SUCCESS != (rval = delete_entities( &*i, 1)))
result = rval;
return rval;
}
@@ -2592,7 +2366,13 @@
MBErrorCode MBCore::add_parent_meshset( MBEntityHandle meshset,
const MBEntityHandle parent_meshset)
{
- return add_parent_meshsets( meshset, &parent_meshset, 1 );
+ MBMeshSet* set_ptr = get_mesh_set( sequence_manager(), meshset );
+ MBMeshSet* parent_ptr = get_mesh_set( sequence_manager(), parent_meshset );
+ if (!set_ptr || !parent_ptr)
+ return MB_ENTITY_NOT_FOUND;
+
+ set_ptr->add_parent( parent_meshset );
+ return MB_SUCCESS;
}
MBErrorCode MBCore::add_parent_meshsets( MBEntityHandle meshset,
@@ -2607,21 +2387,21 @@
if (!get_mesh_set( sequence_manager(), parents[i] ))
return MB_ENTITY_NOT_FOUND;
-#ifdef MOAB_WITH_REFCOUNT
for (int i = 0; i < count; ++i)
- if (set_ptr->add_parent( parents[i] ))
- increment_reference_count( parents + i, 1 );
-#else
- for (int i = 0; i < count; ++i)
set_ptr->add_parent( parents[i] );
-#endif
return MB_SUCCESS;
}
MBErrorCode MBCore::add_child_meshset(MBEntityHandle meshset,
const MBEntityHandle child_meshset)
{
- return add_child_meshsets( meshset, &child_meshset, 1 );
+ MBMeshSet* set_ptr = get_mesh_set( sequence_manager(), meshset );
+ MBMeshSet* child_ptr = get_mesh_set( sequence_manager(), child_meshset );
+ if (!set_ptr || !child_ptr)
+ return MB_ENTITY_NOT_FOUND;
+
+ set_ptr->add_child( child_meshset );
+ return MB_SUCCESS;
}
MBErrorCode MBCore::add_child_meshsets( MBEntityHandle meshset,
@@ -2636,14 +2416,8 @@
if (!get_mesh_set( sequence_manager(), children[i] ))
return MB_ENTITY_NOT_FOUND;
-#ifdef MOAB_WITH_REFCOUNT
for (int i = 0; i < count; ++i)
- if (set_ptr->add_child( children[i] ))
- increment_reference_count( children+i, 1 );
-#else
- for (int i = 0; i < count; ++i)
set_ptr->add_child( children[i] );
-#endif
return MB_SUCCESS;
}
@@ -2655,16 +2429,9 @@
MBMeshSet* child_ptr = get_mesh_set( sequence_manager(), child );
if (!parent_ptr || !child_ptr)
return MB_ENTITY_NOT_FOUND;
-
-#ifdef MOAB_WITH_REFCOUNT
- if (parent_ptr->add_child( child ))
- increment_reference_count( &child, 1 );
- if (child_ptr->add_parent( parent ))
- increment_reference_count( &parent, 1 );
-#else
+
parent_ptr->add_child( child );
child_ptr->add_parent( parent );
-#endif
return MB_SUCCESS;
}
@@ -2676,15 +2443,8 @@
if (!parent_ptr || !child_ptr)
return MB_ENTITY_NOT_FOUND;
-#ifdef MOAB_WITH_REFCOUNT
- if (parent_ptr->remove_child( child ))
- decrement_reference_count( &child, 1 );
- if (child_ptr->remove_parent( parent ))
- decrement_reference_count( &parent, 1 );
-#else
parent_ptr->remove_child( child );
child_ptr->remove_parent( parent );
-#endif
return MB_SUCCESS;
}
@@ -2695,12 +2455,7 @@
MBMeshSet* set_ptr = get_mesh_set( sequence_manager(), meshset );
if (!set_ptr)
return MB_ENTITY_NOT_FOUND;
-#ifdef MOAB_WITH_REFCOUNT
- if (set_ptr->remove_parent( parent_meshset ))
- decrement_reference_count( &parent_meshset, 1 );
-#else
set_ptr->remove_parent( parent_meshset );
-#endif
return MB_SUCCESS;
}
@@ -2710,12 +2465,7 @@
MBMeshSet* set_ptr = get_mesh_set( sequence_manager(), meshset );
if (!set_ptr)
return MB_ENTITY_NOT_FOUND;
-#ifdef MOAB_WITH_REFCOUNT
- if (set_ptr->remove_child( child_meshset ))
- decrement_reference_count( &child_meshset, 1 );
-#else
set_ptr->remove_child( child_meshset );
-#endif
return MB_SUCCESS;
}
@@ -3147,265 +2897,3 @@
tag_array, num_tags,
tag_storage, amortized_tag_storage );
}
-
-#ifdef MOAB_WITH_REFCOUNT
-
-MBErrorCode MBCore::increment_reference_count( const MBEntityHandle* array, size_t count )
-{
- MBErrorCode result = MB_SUCCESS, tmp;
- for (size_t i = 0; i < count; ++i) {
- MBEntitySequence* seq;
- tmp = sequence_manager()->find( array[i], seq );
- if (MB_SUCCESS != tmp)
- result = tmp;
- else if (!seq->is_valid_entity(array[i]))
- result = MB_ENTITY_NOT_FOUND;
- else
- seq->increment_reference_count( array[i] );
- }
- return result;
-}
-
-MBErrorCode MBCore::decrement_reference_count( const MBEntityHandle* array, size_t count )
-{
- MBErrorCode result = MB_SUCCESS, tmp;
- for (size_t i = 0; i < count; ++i) {
- MBEntitySequence* seq;
- tmp = sequence_manager()->find( array[i], seq );
- if (MB_SUCCESS != tmp)
- result = tmp;
- else if (!seq->is_valid_entity(array[i]))
- result = MB_ENTITY_NOT_FOUND;
- else
- seq->decrement_reference_count( array[i] );
- }
- return result;
-}
-
-unsigned MBCore::get_reference_count( MBEntityHandle handle )
-{
- MBEntitySequence* seq;
- MBErrorCode rval = sequence_manager()->find( handle, seq );
- return MB_SUCCESS == rval ? seq->get_reference_count(handle) : 0;
-}
-
-MBErrorCode MBCore::decrement_all_referenced_entities( MBEntityHandle handle,
- const std::vector<MBTag>& handle_tags )
-{
- MBEntitySequence* seq;
- MBErrorCode rval = sequence_manager()->find( handle, seq );
- if (MB_SUCCESS != rval)
- return rval;
-
- seq->decrement_all_referenced_entities( handle, a_entity_factory() );
-
- rval = a_entity_factory()->decrement_referenced_entities( handle );
- if (MB_SUCCESS != rval) {
- seq->increment_all_referenced_entities( handle, a_entity_factory() );
- return rval;
- }
-
- std::vector<MBEntityHandle> tag_data;
- for (std::vector<MBTag>::const_iterator i = handle_tags.begin();
- i != handle_tags.end(); ++i) {
- int size;
- tag_get_size( *i, size );
- size /= sizeof(MBEntityHandle);
- tag_data.resize( size );
- rval = tag_server()->get_data( *i, &handle, 1, &tag_data[0] );
- if (MB_SUCCESS == rval)
- decrement_reference_count( &tag_data[0], size );
- }
- return MB_SUCCESS;
-}
-
-
-MBErrorCode MBCore::increment_all_referenced_entities( MBEntityHandle handle,
- const std::vector<MBTag>& handle_tags )
-{
- MBEntitySequence* seq;
- MBErrorCode rval = sequence_manager()->find( handle, seq );
- if (MB_SUCCESS != rval)
- return rval;
-
- seq->increment_all_referenced_entities( handle, a_entity_factory() );
-
- rval = a_entity_factory()->increment_referenced_entities( handle );
- if (MB_SUCCESS != rval) {
- seq->decrement_all_referenced_entities( handle, a_entity_factory() );
- return rval;
- }
-
- std::vector<MBEntityHandle> tag_data;
- for (std::vector<MBTag>::const_iterator i = handle_tags.begin();
- i != handle_tags.end(); ++i) {
- int size;
- tag_get_size( *i, size );
- size /= sizeof(MBEntityHandle);
- tag_data.resize( size );
- rval = tag_server()->get_data( *i, &handle, 1, &tag_data[0] );
- if (MB_SUCCESS == rval)
- increment_reference_count( &tag_data[0], size );
- }
- return MB_SUCCESS;
-}
-
-#else
-
-MBErrorCode MBCore::increment_reference_count( const MBEntityHandle* , size_t )
-{
- abort();
- return MB_FAILURE;
-}
-
-MBErrorCode MBCore::decrement_reference_count( const MBEntityHandle* , size_t )
-{
- abort();
- return MB_FAILURE;
-}
-
-unsigned MBCore::get_reference_count( MBEntityHandle )
-{
- abort();
- return (unsigned)-1;
-}
-
-MBErrorCode MBCore::decrement_all_referenced_entities( MBEntityHandle,
- const std::vector<MBTag>& )
-{
- abort();
- return MB_FAILURE;
-}
-
-
-MBErrorCode MBCore::increment_all_referenced_entities( MBEntityHandle ,
- const std::vector<MBTag>& )
-{
- abort();
- return MB_FAILURE;
-}
-
-#endif
-
-
-MBErrorCode MBCore::find_all_referencing_entities( MBEntityHandle entity,
- MBRange& results )
-{
- MBErrorCode rval;
- MBRange entities;
-
- // if entity is a vertex, check all connectivity lists
- if (TYPE_FROM_HANDLE(entity) == MBVERTEX) {
- for (MBEntityType t = MBEDGE; t < MBENTITYSET; ++t) {
- if (t == MBPOLYHEDRON)
- continue;
- entities.clear();
- rval = get_entities_by_type( 0, t, entities );
- if (MB_SUCCESS != rval)
- return rval;
- for (MBRange::iterator i = entities.begin(); i != entities.end(); ++i) {
- const MBEntityHandle* conn;
- int len;
- rval = get_connectivity( *i, conn, len );
- if (MB_SUCCESS != rval)
- return rval;
- if (std::find( conn, conn+len, entity ) - conn < len)
- results.insert( *i );
- }
- }
- }
-
- // if entity type is a face, check polyhedron connectivity
- if (MBCN::Dimension( TYPE_FROM_HANDLE(entity) ) == 2) {
- entities.clear();
- rval = get_entities_by_type( 0, MBPOLYHEDRON, entities );
- if (MB_SUCCESS != rval)
- return rval;
- for (MBRange::iterator i = entities.begin(); i != entities.end(); ++i) {
- const MBEntityHandle* conn;
- int len;
- rval = get_connectivity( *i, conn, len );
- if (MB_SUCCESS != rval)
- return rval;
- if (std::find( conn, conn+len, entity ) - conn < len)
- results.insert( *i );
- }
- }
-
- // check all adjacnecy data
- entities.clear();
- rval = get_entities_by_handle( 0, entities );
- if (MB_SUCCESS != rval)
- return rval;
-
- for (MBRange::iterator i = entities.begin(); i != entities.end(); ++i) {
- const MBEntityHandle* adj;
- int len;
- rval = a_entity_factory()->get_adjacencies( *i, adj, len );
- if (MB_SUCCESS != rval)
- return rval;
-
- if (std::find( adj, adj+len, entity ) - adj < len)
- results.insert( *i );
- }
-
- // check set contents
- entities.clear();
- rval = get_entities_by_type( 0, MBENTITYSET, entities );
- if (MB_SUCCESS != rval)
- return rval;
- for (MBRange::iterator i = entities.begin(); i != entities.end(); ++i) {
- MBRange contents;
- rval = get_entities_by_handle( *i, contents );
- if (contents.find( entity ) != contents.end())
- results.insert( *i );
- }
-
- // if entity is a set, check set parent/child links
- if (TYPE_FROM_HANDLE(entity) == MBENTITYSET) {
- for (MBRange::iterator i = entities.begin(); i != entities.end(); ++i) {
- MBRange parents, children;
- rval = get_parent_meshsets( *i, parents );
- if (MB_SUCCESS != rval)
- return rval;
- rval = get_child_meshsets( *i, children );
- if (MB_SUCCESS != rval)
- return rval;
- if (parents.find(entity) != parents.end() || children.find(entity) != children.end())
- results.insert( *i );
- }
- }
-
- // check all handle tags
- std::vector<MBTag> tags;
- rval = tag_server()->get_tags( MB_TYPE_HANDLE, tags );
- while (!tags.empty()) {
- MBTag tag = tags.back();
- tags.pop_back();
- int size;
- rval = tag_get_size( tag, size );
- if (MB_SUCCESS != rval)
- return rval;
- std::vector<MBEntityHandle> tag_values(size/sizeof(MBEntityHandle));;
-
- for (MBEntityType t = MBVERTEX; t <= MBENTITYSET; ++t) {
- entities.clear();
- rval = get_entities_by_type_and_tag( 0, t, &tag, 0, 1, entities );
- if (MB_SUCCESS != rval)
- return rval;
-
- for (MBRange::iterator i = entities.begin(); i != entities.end(); ++i) {
- rval = tag_get_data( tag, &*i, 1, &tag_values[0] );
- if (MB_SUCCESS != rval)
- return rval;
- if (std::find(tag_values.begin(), tag_values.end(), entity) != tag_values.end())
- results.insert( *i );
- }
- }
- }
-
- return MB_SUCCESS;
-}
-
-
-
Modified: MOAB/trunk/MBCore.hpp
===================================================================
--- MOAB/trunk/MBCore.hpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/MBCore.hpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -950,17 +950,6 @@
virtual const MBProcConfig& proc_config() const
{ return procInfo; }
- MBErrorCode increment_reference_count( MBEntityHandle h )
- { return increment_reference_count( &h, 1 ); }
- MBErrorCode decrement_reference_count( MBEntityHandle h )
- { return decrement_reference_count( &h, 1 ); }
- MBErrorCode increment_reference_count( const MBEntityHandle* handles, size_t size );
- MBErrorCode decrement_reference_count( const MBEntityHandle* handles, size_t size );
- unsigned get_reference_count( MBEntityHandle handle );
- MBErrorCode decrement_all_referenced_entities( MBEntityHandle handle, const std::vector<MBTag>& handle_tags );
- MBErrorCode increment_all_referenced_entities( MBEntityHandle handle, const std::vector<MBTag>& handle_tags );
-
- MBErrorCode find_all_referencing_entities( MBEntityHandle entity, MBRange& results );
private:
void estimated_memory_use_internal( const MBRange* ents,
@@ -975,8 +964,6 @@
unsigned long* tag_storage,
unsigned long* amortized_tag_storage );
- MBErrorCode delete_entity( MBEntityHandle handle );
-
const MBProcConfig procInfo;
//! database init and de-init routines
Deleted: MOAB/trunk/MBFileReadTool.cpp
===================================================================
--- MOAB/trunk/MBFileReadTool.cpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/MBFileReadTool.cpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -1,324 +0,0 @@
-/*
- * MOAB, a Mesh-Oriented datABase, is a software component for creating,
- * storing and accessing finite element mesh data.
- *
- * Copyright 2004 Sandia Corporation. Under the terms of Contract
- * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government
- * retains certain rights in this software.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- */
-
-/**\file MBFileReadTool.cpp
- *\author Jason Kraftcheck <kraftche at cae.wisc.edu>
- *\date 2007-08-21
- */
-
-#include "MBFileReadTool.hpp"
-
-MBFileReadToolBase( MBCore* moab )
- : mMOAB( moab ), fileSet( 0 ),
- parallelRank( moab->proc_config().rank() )
-{ }
-
-void MBFileReadToolBase::report_error( std::string err )
-{
- mMOAB->get_error_handler()->set_last_error( err );
-}
-
-void MBFileReadToolBase::report_error( const char* fmt, ... )
-{
- va_list args;
- va_start(args, fmt);
- mMOAB->get_error_handler()->set_last_error( fmt, args );
- va_end( args );
-}
-
-MBErrorCode MBFileReadToolBase::delete_all_entities()
-{
- MBErrorCode rval;
- MBRange list;
-
- if (fileSet == 0) // all entities already deleted
- return MB_SUCCESS;
-
- rval = moab()->get_entities_by_handle( fileSet, list );
- if (MB_SUCCESS != rval)
- return rval;
-
- list.insert( fileSet );
- rval = moab()->delete_entities( list );
- if (MB_SUCCESS != rval)
- return rval;
-
- fileSet = 0;
- return MB_SUCCESS;
-}
-
-MBErrorCode MBFileReadToolBase::delete_non_tagged_entities(
- const char* tagname,
- const int* tag_values,
- int num_tag_values )
-{
- MBErrorCode rval;
-
- // no entities?
- if (fileSet == 0) {
- report_error( "No entities with tag \"%s\" in file.\n", tagname );
- return MB_FAILURE;
- }
-
- // get tag
- MBTag tag;
- rval = moab()->tag_get_handle( tagname, tag );
- if (MB_SUCCESS != rval) {
- report_error( "Tag not found: \"%s\"\n", tagname );
- return rval;
- }
-
- // check type of tag data
- MBDataType type;
- int size = 0;
- moab()->tag_get_size( tag, size );
- moab()->tag_get_type( tag, type );
- if (size != sizeof(int) || (type != MB_TYPE_INTEGER && type != MB_TYPE_OPAQUE)) {
- report_error( "Invalid type for tag \"%s\"\n", tagname );
- return MB_TYPE_OUT_OF_RANGE;
- }
-
- // construct argument arrays
- std::vector<MBTag> taghandles( num_tag_values ? num_tag_values : 1, tag );
- std::vector<const void*> tagvals( num_tag_values );
- for (int i = 0; i < num_tag_values; ++i)
- tagvals[i] = tag_values + i;
-
- // get entity sets with specified tag
- MBRange sets;
- rval = moab()->get_entities_by_type_and_tag( fileSet,
- MBENTITYSET,
- &taghandles[0],
- num_tag_values ? &tagvals[0] : 0,
- taghandles.size(),
- sets,
- MBInterface::UNION );
-
- // get closure of entity sets
- MBRange entities, temp;
- MBRange::iterator iter;
- // recursively descend all containd and child entity sets
- std::set<MBEntityHandle> visited;
- std::vector<MBEntityHandle> children;
- while (!sets.empty()) {
- MBEntityHandle entset = sets.pop_front();
- if (!visited.insert(entset).first)
- continue;
- entities.insert( entset );
-
- temp.clear();
- moab()->get_entities_by_handle( entset, temp );
- iter = temp.lower_bound( MBENTITYSET );
- entities.merge( temp.begin(), iter );
- std::copy( iter, temp.end(), mb_range_inserter( sets ) );
-
- children.clear();
- rval = moab()->get_child_meshsets( entset, children );
- if (MB_SUCCESS != rval)
- return rval;
- std::copy( children.begin(), children.end(), mb_range_inserter( sets ) );
- }
- // get faces for all polyhedra
- const MBEntityHandle* conn;
- int len;
- iter = entities.lower_bound( MBPOLYHEDRON );
- for (; iter != entities.end() && TYPE_FROM_HANDLE(*iter) < MBENTITYSET; ++iter) {
- rval = moab()->get_connectivity( *iter, conn, len );
- if (MB_SUCCESS != rval)
- return rval;
- std::copy( conn, conn+len, mb_range_inserter( entities ) );
- }
- // get vertices for all elements
- iter = entities.lower_bound( MBEDGE );
- for (; iter != entities.end() && TYPE_FROM_HANDLE(*iter) < MBPOLYHEDRON; ++iter) {
- rval = moab()->get_connectivity( *iter, conn, len );
- if (MB_SUCCESS != rval)
- return rval;
- std::copy( conn, conn+len, mb_range_inserter( entities ) );
- }
-
- // We now have the list of entities to keep.
- // Get the list of entities to remove.
- MBRange all, dead;
- moab()->get_entities_by_handle( fileSet, all );
- dead = all.subtract( entities );
-
- // Destroy the entities
- rval = moab()->remove_entities( fileSet, dead );
- if (MB_SUCCESS != rval)
- return rval;
- rval = moab()->delete_entities( dead );
- if (MB_SUCCESS != rval)
- return rval;
-
- return MB_SUCCESS;
-}
-
-MBErrorCode MBFileReadToolBase::create_sequence( MBEntityID start_id,
- MBEntityID count,
- MBEntityID type,
- MBEntityID conn_len,
- const int* proc_id,
- MBEntitySequence*& seq )
-{
- MBErrorCode rval;
-
- // if we haven't created a set for all file entities yet,
- // do it now
- if (!fileSet) {
- rval = moab()->create_meshset( MESHSET_SET, fileSet );
- if (MB_SUCCESS != rval) {
- fileSet =0;
- return rval;
- }
- }
-
- const int proc = proc_id ? *proc_id : parallel_rank();
- MBEntitySequence* seq = 0;
- rval = mMOAB->sequence_manager()->create_entity_sequence(
- type,
- count,
- conn_len,
- start_id,
- proc,
- start_handle,
- seq );
- if (MB_SUCCESS != rval)
- return rval;
-
- MBRange new_handles( seq->get_start_handle(), seq->get_end_handle() );
- assert( new_handles.size() == count );
- rval = moab()->add_entites( fileSet, new_handles );
- if (MB_SUCCESS != rval) {
- delete seq;
- return rval;
- }
-
- return MB_SUCCESS;
-}
-
-
-MBErrorCode MBFileReadToolBase::get_node_arrays(
- MBEntityID preferred_start_id,
- MBEntityID count,
- MBEntityHandle& start_handle,
- double *& x, double *& y, double *& z,
- const int* proc_id )
-{
- MBEntitySequence* seq = 0;
- MBErrorCode rval = create_sequence( preferred_start_id,
- count,
- MBVERTEX,
- 0,
- proc_id,
- seq );
- if (MB_SUCCESS != rval)
- return rval;
-
- VertexEntitySequence* vseq = static_cast<VertexEntitySequence*>(seq);
- vseq->get_coordinate_arrays( x, y, z );
-
- start_handle = seq->get_start_handle();
- return MB_SUCCESS;
-}
-
-MBErrorCode MBFileReadToolBase::create_element_array(
- MBEntityID preferred_start_id,
- MBEntityID count,
- MBEntityType type,
- MBEntityID conn_length,
- MBEntityHandle& start_handle,
- MBEntityHandle*& conn_array,
- int** last_index_array = 0,
- const int* proc_id )
-{
- // caller needs last_index_array for poly-type elements
- if (type == POLYGON || type == POLYHEDRON) {
- if (!last_index_array)
- return MB_FAILURE;
- }
- // no last_index_array for other element types
- else if (last_index_array)
- *last_index_array = 0;
-
- MBEntitySequence* seq = 0;
- MBErrorCode rval = create_sequence( preferred_start_id,
- count,
- type,
- conn_length,
- proc_id,
- seq );
- if (MB_SUCCESS != rval)
- return rval;
-
- if (type == POLYGON || type == POLYHEDRON) {
- PolyEntitySequence* pseq = static_cast<PolyEntitySequence*>(seq);
- pseq->get_connectivity_array( conn_array );
- pseq->get_index_array( *last_index_array );
- }
- else {
- ElementEntitySequence* eseq = static_cast<ElementEntitySequence*>(seq);
- eseq->get_connectivity_array( conn_array );
- }
-
- start_handle = seq->get_start_handle();
- return MB_SUCCESS;
-}
-
-MBErrorCode MBFileReadToolBase::create_meshset_block( MBEntityID start_id,
- MBEntityID count,
- MBEntityHandle& start_handle,
- unsigned flags,
- const int* proc_id )
-{
- std::vector<unsigned> flag_array( count, flags );
- return create_meshset_block( start_id, count, start_handle, &flag_array[0], proc_id );
-}
-
-MBErrorCode MBFileReadToolBase::create_meshset_block( MBEntityID start_id,
- MBEntityID count,
- MBEntityHandle& start_handle,
- const unsigned* flags,
- const int* proc_id )
-{
- MBErrorCode rval;
-
- const int proc = proc_id ? *proc_id : parallel_rank();
- MBEntitySequence* seq;
- rval = mMOAB->sequence_manager()->create_meshset_sequence( count,
- start_id,
- proc,
- flags,
- seq );
- if (MB_SUCCESS != rval)
- return rval;
-
- start_handle = seq->get_start_handle();
- return MB_SUCCESS;
-}
-
-MBErrorCode MBFileReadToolBase::set_tag_data( MBTag tag,
- MBEntityHandle beg,
- MBEntityHandle num,
- const void* data )
-{
- if (num == 0)
- return MB_SUCCESS;
-
- MBRange range( beg, beg + num - 1 );
- return moab()->tag_set_data( tag, range, data );
-}
-
-
Deleted: MOAB/trunk/MBFileReadTool.hpp
===================================================================
--- MOAB/trunk/MBFileReadTool.hpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/MBFileReadTool.hpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -1,909 +0,0 @@
-/*
- * MOAB, a Mesh-Oriented datABase, is a software component for creating,
- * storing and accessing finite element mesh data.
- *
- * Copyright 2004 Sandia Corporation. Under the terms of Contract
- * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government
- * retains certain rights in this software.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- */
-
-/**\file MBFileReadTool.hpp
- *\author Jason Kraftcheck <kraftche at cae.wisc.edu>
- *\date 2007-04-25
- */
-
-#ifndef MB_FILE_READ_TOOL_HPP
-#define MB_FILE_READ_TOOL_HPP
-
-#include "RangeMap.hpp"
-
-#include <iosfwd>
-
-class MBCore;
-class MBError;
-
-/**\brief Non-template portions of MBFileReadTool */
-class MBFileReadToolBase {
-public:
-
- MBFileReadToolBase( MBCore* moab );
-
- /**\brief Set last error message */
- void report_error( std::string error );
-
- /**\brief Set last error message */
- void report_error( const char* error, ... )
-#ifdef __GNUC__
- __attribute__((format(printf,2,3)))
-#endif
- ;
-
- inline MBInterface* moab() const
- { return mMOAB; }
-
- inline unsigned parallel_rank() const
- { return parallelRank; }
-
- /**\brief delete all read entities
- *
- * Delete all entities created through the methods
- * provided by this class.
- */
- MBErrorCode delete_all_entities();
-
- /**\brief Get entity set containing all read entities
- *
- * Get a new entity set containing all the entities
- * allocated via methods of this object.
- */
- inline MBEntityHandle get_file_set() const
- { return fileSet; }
-
- /**\brief Delete entities with specified tag
- *
- * Delete all entities read from file that do not have
- * the specified tag or tag values.
- *\param tagname The name of the tag -- must have single integer value
- *\param tag_values If not null, a list of integer tag values
- *\param num_tag_values The length of tag_values
- */
- MBErrorCode delete_non_tagged_entities( const char* tagname,
- const int* tag_values = 0,
- int num_tag_values = 0 );
-
-protected:
-
- /**\brief Allocate vertex sequence
- *
- * Allocate a vertex sequence and update any bookkeeping in
- * this object.
- *\param preferred_start_id First MBEntityID, if available
- *\param count Number of vertices to allocate
- *\param start_handle Output: first vertex handle
- *\param x Output: MOAB internal storage for vertex X-coordinates.
- *\param y Output: MOAB internal storage for vertex Y-coordinates.
- *\param z Output: MOAB internal storage for vertex Z-coordinates.
- *\param proc_id NULL or requested parallel processor ID
- */
- MBErrorCode get_node_arrays( MBEntityID preferred_start_id,
- MBEntityID count,
- MBEntityHandle& start_handle,
- double *& x, double *& y, double *& z,
- const int* proc_id );
-
- /**\brief Allocate element sequence
- *
- * Allocate a element sequence and update any bookkeeping in
- * this object.
- *\param preferred_start_id First MBEntityID, if available
- *\param count Number of elements to allocate
- *\param type Element type
- *\param conn_length Vertices per element, zero for MBPOLYGON and MBPOLYHEDRON
- *\param start_handle Output: first vertex handle
- *\param conn_array Output: MOAB internal storage for element connectivity
- *\param last_index_array Cannot be NULL for MBPOLYGON or MBPOLYHEDRON. Must
- * be NULL for other types. Output: Pointer to MOAB
- * internal storage of last index in connectivity
- * array for each element.
- *\param proc_id NULL or requested parallel processor ID
- */
- MBErrorCode get_element_array( MBEntityID preferred_start_id,
- MBEntityID count,
- MBEntityType type,
- MBEntityID conn_length,
- MBEntityHandle& start_handle,
- MBEntityHandle*& conn_array,
- int** last_index_array = 0,
- const int* proc_id );
-
- /**\brief Allocate a meshset sequence
- *
- * Allocate a meshset sequence and update any bookkeeping in
- * this object.
- *\param preferred_start_id First MBEntityID, if available
- *\param count Number of entity sets to allocate
- *\param start_handle Output: first entity set handle
- *\param flags entity set creation flags (one val for all entity sets)
- *\param proc_id NULL or requested parallel processor ID
- */
- MBErrorCode create_meshset_block( MBEntityID preferred_start_id,
- MBEntityID count,
- MBEntityHandle& start_handle_out,
- unsigned flags,
- const int* proc_id )
-
- /**\brief Allocate a meshset sequence
- *
- * Allocate a meshset sequence and update any bookkeeping in
- * this object.
- *\param preferred_start_id First MBEntityID, if available
- *\param count Number of entity sets to allocate
- *\param start_handle Output: first entity set handle
- *\param flags entity set creation flags (one val per entity sets)
- *\param proc_id NULL or requested parallel processor ID
- */
- MBErrorCode create_meshset_block( MBEntityID preferred_start_id,
- MBEntityID count,
- MBEntityHandle& start_handle_out,
- const unsigned* flags,
- const int* proc_id )
-
- /**\brief Set tag data for a block of entity handles. */
- MBErrorCode set_tag_data( MBTag tag,
- MBEntityHandle beg,
- MBEntityHandle count,
- const void* data );
-
-private:
-
- MBErrorCode create_sequence( MBEntityID start_id,
- MBEntityID count,
- MBEntityID type,
- MBEntityID conn_len,
- const int* proc_id,
- MBEntitySequence*& seq );
-
- MBCore* mMOAB;
- MBEntityHandle fileSet;
- unsigned parallelRank;
-};
-
-/**\brief Helper class for file readers.
- *
- * This class provides methods for creation of entities
- * in MOAB and maintains a map from file IDs to MBEntityHandles.
- * All methods accept values as file IDs and map them to MBEntityHandles
- * internally.
- *
- * The type of a file ID is a template parameter, allowing a
- * particular reader to work directly with the identifier/index
- * type used by an underlying IO library.
- */
-template <typename FileIDType>
-class MBFileReadTool : public MBFileReadToolBase
-{
-public:
-
- /**\brief Create reader tool
- *
- *\param vertex_unique_ids File ID space for vertices is separate from
- * other entities. If this value is true, then
- * the file may contain both a vertex with ID 1
- * and an element with the same ID value of 1.
- *\param element_type_unique_ids File ID space is separate for different
- * element types. If this value is true, then
- * the file may contain an edge and a
- * triangle element that have the same ID.
- *\param set_unique_ids File ID space for entity sets is separate from
- * other entities.
- */
- inline
- MBFileReadTool( MBCore* moab_instance,
- bool vertex_unique_ids,
- bool element_type_unique_ids,
- bool set_unique_ids );
-
- /**\brief Allocate a block of nodes.
- *
- * Allocate a block of nodes and return pointers to MOAB's internal
- * storage of the vertex coordinaets for those nodes, such that the
- * file reader may read the coordinate values directly into the
- * vertex storage allocated by this method.
- *
- *\param start_id The file ID (or index) of the first vertex. The
- * allocated vertices will be assigned file IDs in
- * the range [start_id,start_id+count).
- *\param count Number of vertices to allocate.
- *\param x_array_out Output: location at which to write X-coordinates.
- *\param y_array_out Output: location at which to write Y-coordinates.
- *\param z_array_out Output: location at which to write Z-coordinates.
- *\param proc_id For parallel, ID of processor to associate with entities.
- * If null, current processor rank is assumed.
- */
- inline
- MBErrorCode create_nodes( FileIDType start_id,
- FileIDType count,
- double *& x_array_out,
- double *& y_array_out,
- double *& z_array_out,
- const int* proc_id = 0 );
-
- /**\brief Create a block of elements.
- *
- * Create mesh elements.
- *
- *\param start_id The file ID (or index) of the first vertex. The
- * allocated vertices will be assigned file IDs in
- * the range [start_id,start_id+count).
- *\param count Number of vertices to allocate.
- *\param type The element type.
- *\param connectivity_length Nodes per element. Zero for MBPOLY* types.
- *\param interleaved_connectivity Element connectivity list, specified
- * as vertex IDs as assigned by the create_nodes method
- * of this class (face IDs if type == POLYHEDRON).
- *\param poly_end_indices For MBPOLYGON and MBPOLYHEDRON types, the
- * *last* index in interleaved_connectivity for each element.
- *\param proc_id For parallel, ID of processor to associate with entities.
- * If null, current processor rank is assumed.
- */
- inline
- MBErrorCode create_elements( FileIDType start_id,
- FileIDType count,
- MBEntityType type,
- FileIDType connectivity_length,
- const FileIDType* interleaved_connectivity,
- const FileIDType* poly_end_indices = 0,
- const int* proc_id = 0 );
-
- /**\brief Specifiy explicit adjacencies
- *
- * Create explicit adjacencies between entities.
- *\param from_id Source entity for adjacency
- *\param to_ids Target entities for adjacencies
- *\param to_count Length of to_ids
- *\param from_type Type of source entity. The caller
- * must specify this value if it cannot
- * be inferred from the source entity ID
- * (see constructor arguments.)
- *\param to_type Type of target entities. The caller
- * must specify this value if it cannot
- * be inferred from the target entity IDs
- * (see constructor arguments.)
- */
- inline
- MBErrorCode add_adjacencies( FileIDType from_id,
- const FileIDType* to_ids,
- FileIDType to_count,
- MBEntityType from_type = MBMAXTYPE,
- MBEntityType to_type = MBMAXTYPE );
-
- /**\brief Create tag for storing entity handles.
- *
- *\param name Tag name
- *\param num_handles Number of handles in each tag value. If
- * this value is greater than one, then each
- * entity has an array of handles for this tag.
- *\param storage_type Tag storage type.
- *\param handle_out Output: tag handle
- *\param mesh_value Global, or mesh value for tag.
- *\param default_value Default value for tag.
- *\param null_id If non-null, the value pointed to by this
- * argument is treated as special: a "NULL" file ID.
- */
- inline
- MBErrorCode create_entity_handle_tag( const char* name,
- unsigned num_handles,
- MBTagType storage_type,
- MBTag& handle_out,
- const FileIDType* mesh_value = 0,
- const FileIDType* default_value = 0,
- const FileIDType* null_id = 0 );
-
- /**\brief Set tag data for a block of entities
- *
- * Set tag data for non-handle type tags. This method will
- * fail if the tag has a data type MB_TAG_HANDLE.
- *
- *\param handle Tag handle
- *\param start_id File ID of first entity
- *\param id_count Number of entities.
- *\param tag_data Tag values
- *\param type The type of the entities for which the tag
- * data is being set. The caller must specify
- * this if it cannot be inferred from the file
- * IDs (see constructor arguments).
- */
- inline
- MBErrorCode set_tag_data( MBTag handle,
- FileIDType start_id,
- FileIDType id_count,
- const void* tag_data,
- MBEntityType type = MBMAXTYPE );
-
- /**\brief Set tag data for entity handle tag for a block of entities
- *
- * This method will fail for any tag that does not have a data type
- * of MB_TYPE_HANDLE.
- *
- *\param handle Tag handle
- *\param start_id File ID of first entity
- *\param id_count Number of entities.
- *\param tag_data Tag values as file IDs
- *\param entity_type The type of the entities for which the tag
- * data is being set. The caller must specify
- * this if it cannot be inferred from the file
- * IDs (see constructor arguments).
- *\param value_type The type of the entities in the tag values.
- * The caller must specify
- * this if it cannot be inferred from the file
- * IDs (see constructor arguments).
- *\param null_id If non-null, the value pointed to by this
- * argument is treated as special: a "NULL" file ID.
- */
- inline
- MBErrorCode set_tag_data( MBTag handle,
- const FileIDType* id_array,
- FileIDType id_count,
- const FileIDType* tag_data,
- MBEntityType entity_type = MBMAXTYPE,
- MBEntityType value_type = MBMAXTYPE,
- const FileIDType* null_id = 0 );
-
- /**\brief Create a block of entity sets
- *
- * Create count entity sets with consecutive file IDs, beginning
- * with the specified start_id.
- *\param start_id File ID for first entity set
- *\param count Number of entity sets to allocate
- *\param options Set creation flags for each entity set.
- *\param proc_id For parallel, ID of processor to associate with entities.
- * If null, current processor rank is assumed.
- */
- inline
- MBErrorCode create_meshsets( FileIDType start_id,
- MBEntityId count,
- const unsigned* options,
- const int* proc_id = 0 );
-
- /**\brief Create a block of entity sets
- *
- * Create count entity sets with consecutive file IDs, beginning
- * with the specified start_id.
- *\param start_id File ID for first entity set
- *\param count Number of entity sets to allocate
- *\param options Set creation flags for each entity set.
- *\param proc_id For parallel, ID of processor to associate with entities.
- * If null, current processor rank is assumed.
- */
- inline
- MBErrorCode create_meshsets( FileIDType start_id,
- FileIDType count,
- unsigned options,
- const int* proc_id = 0 );
-
- /**\brief Specify set contents for a block of entity sets
- *
- *\param start_id File id of first entity set
- *\param count Number of entity sets
- *\param concatenated_content_lists The concatenation of the list of set
- * contents.
- *\param end_indices For each entity set, the index of the last entry
- * for that set in concatenated_content_lists
- *\param type The type of the entities in concatenated_content_list.
- * The caller must specify this value if it cannot be
- * inferred from the file IDs (see constructor args.)
- */
- inline
- MBErrorCode add_meshset_contents( FileIDType start_id,
- FileIDType count,
- const FileIDType* concatenated_content_lists,
- const FileIDType* end_indices ,
- MBEntityType type = MBMAXTYPE );
-
- /**\brief Specify set contents for a block of entity sets
- *
- * Specify contents for a block of entity sets, where the set
- * contents are specified as ranges of file IDs.
- *
- *\param start_id File id of first entity set
- *\param count Number of entity sets
- *\param concatenated_range_list The concatenation of the list of set
- * contents. The contents for each set are specified
- * as pairs of file IDS, where each pair corresponds
- * to the first and last file ID of a range of entities.
- * To specify a single entity, both values in the range
- * pair should be the same.
- *\param end_indices For each entity set, the index of the last entry
- * for that set in concatenated_range_list
- *\param type The type of the entities in concatenated_range_list.
- * The caller must specify this value if it cannot be
- * inferred from the file IDs (see constructor args.)
- */
- inline
- MBErrorCode add_meshset_range_contents( FileIDType start_id,
- FileIDType count,
- const FileIDType* concatenated_range_list,
- const FileIDType* end_indices,
- MBEntityType type = MBMAXTYPE );
-
- /**\brief Specify set children for a block of entity sets
- *
- *\param start_parent_id File id of first entity set
- *\param parent_count Number of entity sets
- *\param concatenated_children_lists The concatenation of the list of set
- * children.
- *\param end_indices For each entity set, the index of the last entry
- * for that set in concatenated_children_lists
- *\param null_id If non-null, the value pointed to by this
- * argument is treated as special: a "NULL" file ID.
- *\param bidirectional If true, also create link from child up to parent.
- * If false, links are single-directional.
- */
- inline
- MBErrorcode add_meshset_children( FileIDType start_parent_id,
- FileIDType parent_count,
- const FileIDType* concatenated_children_lists,
- const FileIDType* end_indices,
- const FileIDType* null_id,
- bool bidirectional = true );
-
- /**\brief Specify set parents for a block of entity sets
- *
- *\param start_child_id File id of first entity set
- *\param child_count Number of entity sets
- *\param concatenated_parents_lists The concatenation of the list of set
- * parents.
- *\param end_indices For each entity set, the index of the last entry
- * for that set in concatenated_parents_lists
- *\param null_id If non-null, the value pointed to by this
- * argument is treated as special: a "NULL" file ID.
- */
- inline
- MBErrorcode add_meshset_parents( FileIDType start_child_id,
- FileIDType child_count,
- const FileIDType* concatenated_parents_lists,
- const FileIDType* end_indices,
- const FileIDType* null_id );
-
- /**\brief Get number of entities of each type */
- inline void get_entity_counts( FileIDType counts[MBMAXTYPE] ) const;
-
-
- /**\brief Convert from file IDs to MBEntityHandles
- *
- * Convert from file IDs to MBEntityHandles
- *
- *\param type The type of the entities, or MBMAXTYPE if
- * the entity type can be inferred from the file ID.
- * The type can be inferred if all arguments to the
- * constructor that control the file ID space mapping
- * are false. I.e. there is to potential ID conflict.
- *\param ids The input array of IDs for which to get the
- * corresponding MBEntityHandles.
- *\param handles The array in which to store the result MBEntityHandles
- *\param count The length of ids (and handles).
- *\param null_id If this argument is not NULL, then the value it points
- * to will be assumed to be a 'NULL' file ID value, such
- * that any input FileIDType with this value will be
- * assigned a zero (NULL) MBEntityHandle.
- *\return true if success, false if failure.
- */
- inline bool ids_to_handles( MBEntityType type,
- const FileIdType* ids,
- MBEntityHandle* handles,
- FileIDType count,
- const FileIDType* null_id = 0 );
-
-private:
- HandleRangeMap<FileIDType> typeMap[MBMAXTYPE+1];
- const bool vertexUniqueIds, elemTypeUniqueIds, setUniqueIds;
- std::vector<MBEntityHandle> handleArray;
-};
-
-template <typename FileIDType> inline
-bool MBFileReadTool<FileIdType>::ids_to_handles( MBEntityType type,
- const FileIdType* ids,
- MBEntityHandle* handles,
- FileIDType count,
- const FileIDType* null_id )
-{
- bool ok = true;
- const HandleRangeMap& map = typeMap[type];
- for (FileIDType i = 0; i < count; ++i) {
- handles[i] = map.find( ids[i] );
- if (!handles[i] && (!null_id || *null_id != ids[i]))
- ok = false;
- }
- return ok;
-}
-
-template <typename FileIDType> inline
-MBFileReadTool<FileIdType>::MBFileReadTool( MBInterface* moab_iface,
- bool vertex_unique_ids,
- bool element_type_unique_ids,
- bool set_unique_ids )
- : MBReaderUtilBase( moab_interface ),
- vertexUniqueIds( vertex_unique_ids ),
- elemTypeUniqueIds( element_type_unique_ids ),
- setUniqueIds( set_unique_ids )
- {}
-
-template <typename FileIDType> inline
-MBErrorCode MBFileReadTool<FileIdType>::create_nodes( FileIDType start_id,
- FileIDType count,
- double *& x,
- double *& y,
- double *& z,
- const int* proc_id )
-{
- MBEntityHandle handle,
- MBErrorCode rval = get_node_arrays( start+id, count, handle, x, y, z, proc_id );
- if (MB_SUCCESS != rval)
- return rval;
-
- typeMap[MBVERTEX].insert( handle, count, start_id );
- if (!vertexUniqueIds)
- typeMap[MBMAXTYPE].insert( handle, count, start_id );
-}
-
-template <typename FileIDType> inline
-MBErrorCode MBFileReadTool<FileIdType>::create_elements( FileIDType start_id,
- FileIDType count,
- MBEntityType type,
- FileIDType len,
- const FileIDType* conn_ids,
- const FileIDType* poly,
- const int* proc_id )
-{
- if (type == MBPOLYGON || type == MBPOLYHEDRON)
- if (!poly || poly[count-1] != len)
- return MB_FAILURE;
-
- int* index_array;
- MBErrorCode rval;
- MBEntityHandle handle, *conn;
-
- rval = get_element_array( start_id, count, type, len, handle, conn, &index_array, proc_id );
- if (MB_SUCCESS != rval)
- return rval;
-
- typeMap[type].insert( handle, count, start_id );
- if (!elemTypeUniqueIds)
- typeMap[MBMAXTYPE].insert( handle, count, start_id );
-
- bool valid;
- if (type != MBPOLYHEDRON)
- valid = convert_ids_to_handles( MBVERTEX, conn_ids, conn, count );
- else if (elemTypeUniqueIDs)
- valid = convert_ids_to_handles( MBPOLYGON, conn_ids, conn, count );
- else
- valid = convert_ids_to_handles( MBMAXTYPE, conn_ids, conn, count );
-
- if (type == MBPOLYGON || type == MBPOLYHEDRON)
- for (FileIDType i = 0; i < count; ++i)
- index_array[i] = poly[i];
-
- return valid ? MB_SUCCESS : MB_FAILURE;;
-}
-
-template <typename FileIDType> inline
-MBErrorCode MBFileReadTool<FileIdType>::add_adjacencies( FileIDType from_id,
- const FileIDType* to_ids,
- FileIDType to_count,
- MBEntityType from_type,
- MBEntityType to_type )
-{
- MBEntityHandle from_handle;
- if (!convert_ids_to_handles( from_type, &from_id, &from_handle, 1 ))
- return MB_FAILURE;
-
- handleArray.resize( to_count );
- if (!convert_ids_to_handles( to_type, to_ids, &handleArray[0], to_count ))
- return MB_FAILURE;
-
- return moab()->add_adjacencies( from_handle, &handleArray[0], to_count, false );
-}
-
-template <typename FileIDType> inline
-MBErrorCode MBFileReadTool<FileIdType>::create_entity_handle_tag(
- const char* name,
- unsigned num_handles,
- MBTagType storage_type,
- MBTag& handle_out,
- const FileIDType* mesh_value,
- const FileIDType* default_value,
- const FileIDType* null_id )
-{
- handleArray.resize( 2*num_handles );
- MBEntityHandle *mesh_handles = 0, *default_handles = 0;
- if (mesh_values) {
- mesh_handles = &handleArray[0];
- if (!ids_to_handles( MBMAXTYPE, mesh_value, mesh_handles, num_handles, null_id ))
- return MB_FAILURE;
- }
- if (default_value) {
- default_handles = &handleArray[num_handles];
- if (!ids_to_handles( MBMAXTYPE, default_value, default_handles, num_handles, null_id ))
- return MB_FAILURE;
- }
-
- MBErrorCode rval = moab()->tag_create( name,
- num_handles * sizeof(MBEntityHandle),
- storage_type,
- MB_TYPE_HANDLE,
- handle_out,
- default_handles,
- true );
- if (MB_SUCCESS != rval)
- return rval;
-
- return tag_set_data( handle_out, 0, 0, mesh_handles );
-}
-
-
-template <typename FileIDType> inline
-MBErrorCode MBFileReadTool<FileIdType>::set_tag_data( MBTag handle,
- FileIDType start_id,
- FileIDType id_count,
- const void* tag_data,
- MBEntityType type,
- MBEntityType val_type )
-{
- MBErrorCode rval, result = MB_SUCCESS;
- std::vector<MBEntityHandle> ranges, hdata;
- if (!typeMap[type].find( start_id, id_count, ranges ))
- return MB_FAILURE;
-
- MBDataType tag_type;
- rval = moab()->tag_get_data_type( handle, tag_type );
- if (MB_SUCCESS != rval)
- return rval;
-
- int tag_size;
- rval = moab()->tag_get_size( handle, tag_size );
- if (MB_SUCCESS != rval)
- return rval;
-
- if (MB_TYPE_HANDLE == tag_type)
- return MB_TYPE_OUT_OF_RANGE;
-
- const char* data = static_cast<const char*>(tag_data);
- for (MBEntityID i = 0; i < ranges.size(); i += 2) {
- MBEntityHandle start_handle = ranges[i];
- MBEntityID count = ranges[i+1];
- rval = set_tag_data( handle, start_handle, count, data );
- if (MB_SUCCESS != rval)
- result = rval;
- data += (count + tag+size);
- }
-
- return result;
-}
-
-template <typename FileIDType> inline
-MBErrorCode MBFileReadTool<FileIdType>::set_tag_data( MBTag handle,
- const FileIDType* id_array,
- FileIDType id_count,
- const FileIDType* tag_data,
- MBEntityType type,
- MBEntityType val_type,
- const FileIDType* null_id )
-{
- MBErrorCode rval;
- MBDataType tag_type;
- rval = moab()->tag_get_data_type( handle, tag_type );
- if (MB_SUCCESS != rval)
- return rval;
-
- if (tag_type != MB_TYPE_HANDLE)
- return MB_TYPE_OUT_OF_RANGE;
-
- int tag_size;
- rval = moab()->tag_get_size( handle, tag_size );
- if (MB_SUCCESS != rval)
- return rval;
-
- tag_size /= sizeof(MBEntityHandle);
- handleArray.resize( id_count * (tag_size + 1) );
- if (!ids_to_handles( val_type,
- tag_data,
- &handlesArray[id_count],
- null_id ))
- return MB_FAILURE;
-
- tag_data = &handlesArray[id_count];
-
- if (!ids_to_handles( type, id_array, &handlesArray[0], id_count ))
- return MB_FAILURE;
-
- return moab()->tag_set_data( handle, &handlesArray[0], id_count, tag_data );
-}
-
-
-template <typename FileIDType> inline
-MBErrorCode MBFileReadTool<FileIdType>::create_meshsets( FileIDType start_id,
- MBEntityId count,
- const unsigned* options,
- const int* proc_id )
-{
- MBEntityHandle h;
- MBErrorCode rval;
-
- rval = craete_meshset_block( start_id, count, h, options, proc_id );
- if (MB_SUCCESS != rval)
- return rval;
-
- typeMap[MBENTITYSET].insert( h, count, start_id );
- if (!setUniqueIDs)
- typeMap[MBMAXTYPE].insert( h, count, start_id );
-
- return MB_SUCCESS;
-}
-
-template <typename FileIDType> inline
-MBErrorCode MBFileReadTool<FileIdType>::create_meshsets( FileIDType start_id,
- FileIDType count,
- unsigned options,
- const int* proc_id )
-{
- MBEntityHandle h;
- MBErrorCode rval;
-
- rval = craete_meshset_block( start_id, count, h, options, proc_id );
- if (MB_SUCCESS != rval)
- return rval;
-
- typeMap[MBENTITYSET].insert( h, count, start_id );
- if (!setUniqueIDs)
- typeMap[MBMAXTYPE].insert( h, count, start_id );
-
- return MB_SUCCESS;
-}
-
-template <typename FileIDType> inline
-MBErrorCode MBFileReadTool<FileIdType>::add_meshset_contents(
- FileIDType start_id,
- FileIDType count,
- const FileIDType* list,
- const FileIDType* end_indices,
- MBEntityType type )
-{
- MBEntityHandle handle;
- FileIDType id, prev = 0, n;
- MBErrorCode result = MB_SUCCESS;
-
- for (FileIDType i = 0; i < count; prev = end_indices[i++]) {
- id = start_id + i;
- if (!ids_to_handles( MBENTITYSET, &id, &handle, 1 )) {
- result = MB_FAILURE;
- continue;
- }
-
- n = end_indices[i] - prev;
- handleArray.resize( n );
- if (!ids_to_handles( type, list+prev, &handleArray[0], n))
- result = MB_FAILURE;
- else if (MB_SUCCESS != moab()->add_entities( handle, &handleArray[0], n ))
- result = MB_FAILURE;
- }
- return result;
-}
-
-
-template <typename FileIDType> inline
-MBErrorCode MBFileReadTool<FileIdType>::add_meshset_range_contents(
- FileIDType start_id,
- FileIDType count,
- const FileIDType* list,
- const FileIDType* end_indices,
- MBEntityType type )
-{
- MBEntityHandle handle;
- FileIDType id, prev = 0, n;
- MBErrorCode rval, result = MB_SUCCESS;
- MBRange range;
- MBRange::iterator h;
-
- for (FileIDType i = 0; i < count; ++i) {
- id = start_id + i;
- if (!ids_to_handles( MBENTITYSET, &id, &handle, 1 )) {
- result = MB_FAILURE;
- prev = end_indices[i];
- continue;
- }
-
- range.clear();
- h = range.begin();
- for ( ; prev < end_indices[i]; prev += 2)
- typeMap[type].find( list[i], list[i+i], range, h );
-
- if (range.size() != count)
- result = MB_FAILURE;
-
- rval = moab()->add_entities( handle, range );
- if (MB_SUCCESS != rval)
- result = rval;
- }
-
- return result;
-}
-
-
-template <typename FileIDType> inline
-MBErrorCode MBFileReadTool<FileIdType>::add_meshset_children(
- FileIDType start_id,
- FileIDType count,
- const FileIDType* list,
- const FileIDType* counts,
- bool bidirectional )
-{
- MBEntityHandle handle;
- FileIDType id, prev = 0, n;
- MBErrorCode result = MB_SUCCESS;
-
- for (FileIDType i = 0; i < count; prev = end_indices[i++]) {
- id = start_id + i;
- if (!ids_to_handles( MBENTITYSET, &id, &handle, 1 )) {
- result = MB_FAILURE;
- continue;
- }
-
- n = end_indices[i] - prev;
- handleArray.resize( n );
- if (!ids_to_handles( MBENTITYSET, list+prev, &handleArray[0], n))
- result = MB_FAILURE;
- else {
- if (bidirectional) {
- for (FileIDType i = 0; i < n; ++i)
- if (MB_SUCCESS != moab()->add_parent_child( handle, handleArray[i] ))
- result = MB_FAILURE;
- }
- else if (MB_SUCCESS != moab()->add_child_meshsets( handle, &handleArray[0], n ))
- result = MB_FAILURE;
- }
- }
- return result;
-}
-
-template <typename FileIDType> inline
-MBErrorCode MBFileReadTool<FileIdType>::add_meshset_parents(
- FileIDType start_id,
- FileIDType count,
- const FileIDType* list,
- const FileIDType* counts )
-{
- MBEntityHandle handle;
- FileIDType id, prev = 0, n;
- MBErrorCode result = MB_SUCCESS;
-
- for (FileIDType i = 0; i < count; prev = end_indices[i++]) {
- id = start_id + i;
- if (!ids_to_handles( MBENTITYSET, &id, &handle, 1 )) {
- result = MB_FAILURE;
- continue;
- }
-
- n = end_indices[i] - prev;
- handleArray.resize( n );
- if (!ids_to_handles( MBENTITYSET, list+prev, &handleArray[0], n))
- result = MB_FAILURE;
- else if (MB_SUCCESS != moab()->add_parent_meshsets( handle, &handleArray[0], n ))
- result = MB_FAILURE;
- }
- return result;
-}
-
-template <typename FileIDType> inline
-void MBFileReadTool<FileIdType>::get_entity_counts( FileIDType counts[MBMAXTYPE] ) const
-{
- for (MBEntityType t = MBVERTEX; t < MBMAXTYPE; ++i)
- counts[t] = typeMap[t].size();
-}
-
-
Modified: MOAB/trunk/MBMeshSet.cpp
===================================================================
--- MOAB/trunk/MBMeshSet.cpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/MBMeshSet.cpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -274,11 +274,6 @@
mAdjFact->remove_adjacency(*iter, mEntityHandle);
}
}
-#ifdef MOAB_WITH_REFCOUNT
- for (MBRange::iterator i = mRange.begin(); i != mRange.end(); ++i)
- mAdjFact->decrement_reference_count( *i );
-#endif
-
mRange.clear();
return MB_SUCCESS;
}
@@ -291,17 +286,7 @@
{
int i;
for(i = 0; i < num_entities; i++)
-#ifndef MOAB_WITH_REFCOUNT
mRange.insert(entities[i]);
-#else
- {
- MBRange::iterator j = MBRange::lower_bound( mRange.begin(), mRange.end(), entities[i] );
- if (j == mRange.end() || *j != entities[i]) {
- mRange.insert( entities[i] );
- mAdjFact->increment_reference_count( entities[i] );
- }
- }
-#endif
if(tracking() && mAdjFact)
{
@@ -316,27 +301,8 @@
MBEntityHandle mEntityHandle,
AEntityFactory* mAdjFact )
{
-#ifdef MOAB_WITH_REFCOUNT
- if (entities.size() > mRange.size()) {
- MBRange::const_iterator i;
- for (i = mRange.begin(); i != mRange.end(); ++i)
- mAdjFact->decrement_reference_count( * i );
-
- mRange.merge( entities );
- for (i = mRange.begin(); i != mRange.end(); ++i)
- mAdjFact->increment_reference_count( * i );
- }
- else {
- // do this in this way because we expect duplicate to be empty
- MBRange duplicate = mRange.intersect( entities );
- for (MBRange::const_iterator i = entities.begin(); i != entities.end(); ++i)
- if (duplicate.find(*i) == duplicate.end())
- mAdjFact->increment_reference_count( *i );
- mRange.merge(entities);
- }
-#else
+
mRange.merge(entities);
-#endif
if(tracking() && mAdjFact)
{
@@ -359,9 +325,6 @@
if(found != mRange.end())
{
mRange.erase(found);
-#ifdef MOAB_WITH_REFCOUNT
- mAdjFact->decrement_reference_count( *iter );
-#endif
if(tracking() && mAdjFact)
mAdjFact->remove_adjacency(*iter, mEntityHandle);
}
@@ -382,9 +345,6 @@
if(found != mRange.end())
{
mRange.erase(found);
-#ifdef MOAB_WITH_REFCOUNT
- mAdjFact->decrement_reference_count( entities[i] );
-#endif
if(tracking() && mAdjFact)
mAdjFact->remove_adjacency(entities[i], mEntityHandle);
}
@@ -408,12 +368,6 @@
MBEntityHandle mEntityHandle,
AEntityFactory* mAdjFact )
{
-#ifdef MOAB_WITH_REFCOUNT
- MBRange::const_iterator i;
- for (i = mRange.begin(); i != mRange.end(); ++i)
- mAdjFact->decrement_reference_count( * i );
-#endif
-
MBRange other_range;
meshset_2->get_entities(other_range);
@@ -430,11 +384,6 @@
mRange.insert(*iter);
}
-#ifdef MOAB_WITH_REFCOUNT
- for (i = mRange.begin(); i != mRange.end(); ++i)
- mAdjFact->increment_reference_count( * i );
-#endif
-
//track owner
if(tracking() && mAdjFact)
{
@@ -468,10 +417,6 @@
MBErrorCode MBMeshSet_Vector::clear( MBEntityHandle mEntityHandle,
AEntityFactory* mAdjFact)
{
-#ifdef MOAB_WITH_REFCOUNT
- mAdjFact->decrement_reference_count( &mVector[0], mVector.size() );
-#endif
-
if(tracking() && mAdjFact)
{
for(std::vector<MBEntityHandle>::iterator iter = mVector.begin();
@@ -508,10 +453,6 @@
mVector.resize(prev_size + num_entities);
std::copy(entities, entities+num_entities, &mVector[prev_size]);
-#ifdef MOAB_WITH_REFCOUNT
- mAdjFact->increment_reference_count( entities, num_entities );
-#endif
-
if(tracking() && mAdjFact)
{
for(int i = 0; i < num_entities; i++)
@@ -530,11 +471,6 @@
unsigned int prev_size = mVector.size();
mVector.resize(prev_size + entities.size());
std::copy(entities.begin(), entities.end(), &mVector[prev_size]);
-
-#ifdef MOAB_WITH_REFCOUNT
- for (MBRange::const_iterator i = entities.begin(); i != entities.end(); ++i)
- mAdjFact->increment_reference_count( *i );
-#endif
if(tracking() && mAdjFact)
{
@@ -556,9 +492,6 @@
{
if(entities.find(*iter) != entities.end())
{
-#ifdef MOAB_WITH_REFCOUNT
- mAdjFact->decrement_reference_count( *iter );
-#endif
if(tracking() && mAdjFact)
mAdjFact->remove_adjacency(*iter, mEntityHandle);
iter = mVector.erase(iter);
@@ -582,9 +515,6 @@
temp_iter = std::find( mVector.begin(), mVector.end(), entities[i]);
if( temp_iter != mVector.end() )
{
-#ifdef MOAB_WITH_REFCOUNT
- mAdjFact->decrement_reference_count( *temp_iter );
-#endif
if(tracking() && mAdjFact)
mAdjFact->remove_adjacency(entities[i], mEntityHandle);
mVector.erase(temp_iter);
@@ -607,10 +537,6 @@
MBEntityHandle mEntityHandle,
AEntityFactory* mAdjFact )
{
-#ifdef MOAB_WITH_REFCOUNT
- mAdjFact->decrement_reference_count( &mVector[0], mVector.size() );
-#endif
-
MBRange other_range;
meshset_2->get_entities(other_range);
@@ -637,10 +563,6 @@
mAdjFact->remove_adjacency(*iter, mEntityHandle);
}
-#ifdef MOAB_WITH_REFCOUNT
- mAdjFact->increment_reference_count( &mVector[0], mVector.size() );
-#endif
-
return MB_SUCCESS;
}
@@ -659,60 +581,3 @@
+ mVector.capacity()*sizeof(MBEntityHandle);
}
-#ifdef MOAB_WITH_REFCOUNT
-
-void MBMeshSet::increment_all_referenced_entities( AEntityFactory* f )
-{
- int count;
- const MBEntityHandle* array;
-
- array = get_children(count);
- f->increment_reference_count( array, count );
-
- array = get_parents(count);
- f->increment_reference_count( array, count );
-
- if (vector_based())
- reinterpret_cast<MBMeshSet_Vector* >(this)->increment_all_referenced_entities( f );
- else
- reinterpret_cast<MBMeshSet_MBRange*>(this)->increment_all_referenced_entities( f );
-}
-
-void MBMeshSet::decrement_all_referenced_entities( AEntityFactory* f )
-{
- int count;
- const MBEntityHandle* array;
-
- array = get_children(count);
- f->decrement_reference_count( array, count );
-
- array = get_parents(count);
- f->decrement_reference_count( array, count );
-
- if (vector_based())
- reinterpret_cast<MBMeshSet_Vector* >(this)->decrement_all_referenced_entities( f );
- else
- reinterpret_cast<MBMeshSet_MBRange*>(this)->decrement_all_referenced_entities( f );
-}
-
-void MBMeshSet_Vector::increment_all_referenced_entities( AEntityFactory* f )
-{
- f->increment_reference_count( &mVector[0], mVector.size() );
-}
-void MBMeshSet_Vector::decrement_all_referenced_entities( AEntityFactory* f )
-{
- f->decrement_reference_count( &mVector[0], mVector.size() );
-}
-
-void MBMeshSet_MBRange::increment_all_referenced_entities( AEntityFactory* f )
-{
- for (MBRange::const_iterator i = mRange.begin(); i != mRange.end(); ++i)
- f->increment_reference_count( *i );
-}
-void MBMeshSet_MBRange::decrement_all_referenced_entities( AEntityFactory* f )
-{
- for (MBRange::const_iterator i = mRange.begin(); i != mRange.end(); ++i)
- f->decrement_reference_count( *i );
-}
-
-#endif
Modified: MOAB/trunk/MBMeshSet.hpp
===================================================================
--- MOAB/trunk/MBMeshSet.hpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/MBMeshSet.hpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -208,11 +208,6 @@
inline unsigned long get_memory_use() const;
-#ifdef MOAB_WITH_REFCOUNT
- void increment_all_referenced_entities( AEntityFactory* f );
- void decrement_all_referenced_entities( AEntityFactory* f );
-#endif
-
protected:
unsigned long parent_child_memory_use() const;
@@ -313,7 +308,7 @@
\
inline unsigned int num_entities_by_dimension(int dimesion) const; \
\
- unsigned long get_memory_use() const;
+ unsigned long get_memory_use() const;
@@ -328,11 +323,6 @@
MESH_SET_VIRTUAL_FUNCTIONS
-#ifdef MOAB_WITH_REFCOUNT
- void decrement_all_referenced_entities( AEntityFactory* f);
- void increment_all_referenced_entities( AEntityFactory* f);
-#endif
-
private:
MBRange mRange;
@@ -349,11 +339,6 @@
MESH_SET_VIRTUAL_FUNCTIONS
-#ifdef MOAB_WITH_REFCOUNT
- void decrement_all_referenced_entities( AEntityFactory* f);
- void increment_all_referenced_entities( AEntityFactory* f);
-#endif
-
private:
static void vector_to_range( std::vector<MBEntityHandle>& vect, MBRange& range );
Modified: MOAB/trunk/MBReadUtil.cpp
===================================================================
--- MOAB/trunk/MBReadUtil.cpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/MBReadUtil.cpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -36,20 +36,6 @@
unsigned MBReadUtil::parallel_rank() const
{ return mMB->proc_config().rank(); }
-
- /** Update reference counts for connectivity links. Does nothing if
- * not compiled with reference counting enabled.
- */
-MBErrorCode MBReadUtil::increment_reference_count(
- const MBEntityHandle* ent_array,
- size_t num_ent )
-{
-#ifdef MOAB_WITH_REFCOUNT
- return mMB->increment_reference_count( ent_array, num_ent );
-#else
- return MB_SUCCESS;
-#endif
-}
MBErrorCode MBReadUtil::get_node_arrays(
const int /*num_arrays*/,
Modified: MOAB/trunk/MBReadUtil.hpp
===================================================================
--- MOAB/trunk/MBReadUtil.hpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/MBReadUtil.hpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -88,12 +88,6 @@
int*& last_index_array,
MBEntityHandle*& connectivity_array
);
-
- /** Update reference counts for connectivity links. Does nothing if
- * not compiled with reference counting enabled.
- */
- virtual MBErrorCode increment_reference_count( const MBEntityHandle* ent_array,
- size_t num_ent );
MBErrorCode create_entity_sets(
MBEntityID num_sets,
Modified: MOAB/trunk/MBReadUtilIface.hpp
===================================================================
--- MOAB/trunk/MBReadUtilIface.hpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/MBReadUtilIface.hpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -109,12 +109,6 @@
MBEntityHandle*& connectivity_array
) = 0;
- /** Update reference counts for connectivity links. Does nothing if
- * not compiled with reference counting enabled.
- */
- virtual MBErrorCode increment_reference_count( const MBEntityHandle* ent_array,
- size_t num_ent ) = 0;
-
virtual MBErrorCode create_entity_sets(
MBEntityID num_sets,
const unsigned* set_flags,
Modified: MOAB/trunk/MBTest.cpp
===================================================================
--- MOAB/trunk/MBTest.cpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/MBTest.cpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -1333,13 +1333,6 @@
if (MB_SUCCESS != rval)
return rval;
}
-
-#ifdef MOAB_WITH_REFCOUNT
- MBCore* core = dynamic_cast<MBCore*>(MB);
- for (int i = 0; i < num_sets; ++i)
- if (core->get_reference_count(sets[i]) != 1)
- return MB_FAILURE;
-#endif
// test adding child meshsets
@@ -1369,7 +1362,7 @@
if (!compare_lists( list, sets+1, 2 ))
return MB_FAILURE;
// try adding child again
- rval = MB->add_child_meshset( sets[0], sets[2] );
+ rval = MB->add_child_meshset( sets[0], sets[1] );
if (MB_SUCCESS != rval) return rval;
list.clear();
rval = MB->get_child_meshsets( sets[0], list );
@@ -1386,7 +1379,7 @@
if (!compare_lists( list, sets+1, 3 ))
return MB_FAILURE;
// try adding child again
- rval = MB->add_child_meshset( sets[0], sets[3] );
+ rval = MB->add_child_meshset( sets[0], sets[1] );
if (MB_SUCCESS != rval) return rval;
list.clear();
rval = MB->get_child_meshsets( sets[0], list );
@@ -1402,14 +1395,6 @@
if (MB_SUCCESS != rval) return rval;
if (!compare_lists( list, sets+1, 4 ))
return MB_FAILURE;
-
-#ifdef MOAB_WITH_REFCOUNT
- for (int i = 1; i < 5; ++i)
- if (core->get_reference_count(sets[i]) != 2)
- return MB_FAILURE;
-#endif
-
-
// make sure range query returns same result
std::sort( list.begin(), list.end() );
@@ -1458,12 +1443,6 @@
if (!list.empty())
return MB_FAILURE;
-#ifdef MOAB_WITH_REFCOUNT
- for (int i = 1; i < 5; ++i)
- if (core->get_reference_count(sets[i]) != 1)
- return MB_FAILURE;
-#endif
-
// test adding parent meshsets
@@ -1493,7 +1472,7 @@
if (!compare_lists( list, sets+1, 2 ))
return MB_FAILURE;
// try adding parent again
- rval = MB->add_parent_meshset( sets[0], sets[2] );
+ rval = MB->add_parent_meshset( sets[0], sets[1] );
if (MB_SUCCESS != rval) return rval;
list.clear();
rval = MB->get_parent_meshsets( sets[0], list );
@@ -1510,7 +1489,7 @@
if (!compare_lists( list, sets+1, 3 ))
return MB_FAILURE;
// try adding parent again
- rval = MB->add_parent_meshset( sets[0], sets[3] );
+ rval = MB->add_parent_meshset( sets[0], sets[1] );
if (MB_SUCCESS != rval) return rval;
list.clear();
rval = MB->get_parent_meshsets( sets[0], list );
@@ -1526,12 +1505,6 @@
if (MB_SUCCESS != rval) return rval;
if (!compare_lists( list, sets+1, 4 ))
return MB_FAILURE;
-
-#ifdef MOAB_WITH_REFCOUNT
- for (int i = 1; i < 5; ++i)
- if (core->get_reference_count(sets[i]) != 2)
- return MB_FAILURE;
-#endif
// make sure range query returns same result
std::sort( list.begin(), list.end() );
@@ -1579,12 +1552,6 @@
rval = MB->get_parent_meshsets( sets[0], list );
if (!list.empty())
return MB_FAILURE;
-
-#ifdef MOAB_WITH_REFCOUNT
- for (int i = 1; i < 5; ++i)
- if (core->get_reference_count(sets[i]) != 1)
- return MB_FAILURE;
-#endif
// setup tests of recursive child query
@@ -1615,13 +1582,6 @@
if (MB_SUCCESS != rval) return rval;
rval = MB->add_child_meshset( sets[5], sets[7] );
if (MB_SUCCESS != rval) return rval;
-
-#ifdef MOAB_WITH_REFCOUNT
- unsigned expref1[num_sets] = { 1, 2, 2, 2, 3, 2, 3, 3, 1, 1 };
- for (int i = 0; i < num_sets; ++i)
- if (core->get_reference_count(sets[i]) != expref1[i])
- return MB_FAILURE;
-#endif
// test query at depth of 1
list.clear();
@@ -1702,13 +1662,7 @@
for (int i = 0; i < 5; ++i)
if (MB_SUCCESS != MB->num_child_meshsets(sets[i], &count) || count)
return MB_FAILURE;
-
-#ifdef MOAB_WITH_REFCOUNT
- for (int i = 0; i < num_sets; ++i)
- if (core->get_reference_count(sets[i]) != 1)
- return MB_FAILURE;
-#endif
-
+
// setup tests of recursive parent query
// 6 7
// / \ / \ .
@@ -1737,12 +1691,6 @@
if (MB_SUCCESS != rval) return rval;
rval = MB->add_parent_meshset( sets[5], sets[7] );
if (MB_SUCCESS != rval) return rval;
-
-#ifdef MOAB_WITH_REFCOUNT
- for (int i = 0; i < num_sets; ++i)
- if (core->get_reference_count(sets[i]) != expref1[i])
- return MB_FAILURE;
-#endif
// test query at depth of 1
list.clear();
@@ -1823,25 +1771,13 @@
for (int i = 0; i < 5; ++i)
if (MB_SUCCESS != MB->num_parent_meshsets(sets[i], &count) || count)
return MB_FAILURE;
-
-#ifdef MOAB_WITH_REFCOUNT
- for (int i = 0; i < num_sets; ++i)
- if (core->get_reference_count(sets[i]) != 1)
- return MB_FAILURE;
-#endif
+
// test combined parent/child links
// test creation
rval = MB->add_parent_child( sets[9], sets[8] );
if (MB_SUCCESS != rval) return rval;
-
-#ifdef MOAB_WITH_REFCOUNT
- if (core->get_reference_count(sets[9]) != 2 ||
- core->get_reference_count(sets[8]) != 2)
- return MB_FAILURE;
-#endif
-
list.clear();
rval = MB->get_child_meshsets( sets[9], list );
if (MB_SUCCESS != rval) return rval;
@@ -1854,7 +1790,6 @@
return MB_FAILURE;
// test deletion of parent/child
-#ifndef MOAB_WITH_REFCOUNT
rval = MB->add_parent_child( sets[7], sets[9] );
if (MB_SUCCESS != rval) return rval;
rval = MB->delete_entities( &sets[9], 1 );
@@ -1870,10 +1805,6 @@
// clean up remaining sets
return MB->delete_entities( sets, 9 );
-#else
- // clean up remaining sets
- return MB->delete_entities( sets, 10 );
-#endif
}
MBErrorCode mb_mesh_sets_set_test( MBInterface* mb )
@@ -1996,19 +1927,6 @@
if( hexes.size() + tets.size() != dim_3_range.size() )
return MB_FAILURE;
-#ifdef MOAB_WITH_REFCOUNT
- MBCore* core = dynamic_cast<MBCore*>(MB);
- if (core->get_reference_count( ms1 ) != 1)
- return MB_FAILURE;
- if (core->get_reference_count( ms2 ) != 1)
- return MB_FAILURE;
- if (core->get_reference_count( ms3 ) != 1)
- return MB_FAILURE;
- std::vector<unsigned> hex_refs;
- for (MBRange::iterator i = hexes.begin(); i != hexes.end(); ++i)
- hex_refs.push_back( core->get_reference_count(*i) );
-#endif
-
//put all hexes in ms1, ms2, ms3
result = MB->add_entities(ms1, hexes); //add ents in a range
if(result != MB_SUCCESS )
@@ -2024,19 +1942,6 @@
if(result != MB_SUCCESS )
return result;
-#ifdef MOAB_WITH_REFCOUNT
- if (core->get_reference_count( ms1 ) != 1)
- return MB_FAILURE;
- if (core->get_reference_count( ms2 ) != 1)
- return MB_FAILURE;
- if (core->get_reference_count( ms3 ) != 1)
- return MB_FAILURE;
- std::vector<unsigned>::iterator j = hex_refs.begin();
- for (MBRange::iterator i = hexes.begin(); i != hexes.end(); ++i, ++j)
- if (core->get_reference_count(*i) != 3+*j)
- return MB_FAILURE;
-#endif
-
//put all tets in ms1, ms2
if(MB->add_entities(ms1, &tets[0], tets.size()) != MB_SUCCESS ) //add ents in a vector
return MB_FAILURE; //to ordered meshset
@@ -2164,21 +2069,15 @@
MB->get_number_entities_by_handle(ms2, num_before);
vec_iter = tets.begin();
result = MB->delete_entities( &(*vec_iter), 1);
-#ifdef MOAB_WITH_REFCOUNT
- if (result == MB_SUCCESS)
- return MB_FAILURE;
-#else
if(result != MB_SUCCESS )
return result;
-#endif
int num_after = 0;
MB->get_number_entities_by_handle(ms2, num_after);
-#ifndef MOAB_WITH_REFCOUNT
if( num_before != num_after + 1)
return MB_FAILURE;
-#endif
+
return MB_SUCCESS;
}
@@ -3088,7 +2987,6 @@
entities.clear();
MB->get_entities_by_type(0, MBVERTEX, entities);
-
unsigned int original_num_nodes = entities.size();
entities.clear();
MB->get_entities_by_type(0, MBHEX, entities);
@@ -3107,7 +3005,6 @@
entities.clear();
MB->get_entities_by_type(0, MBVERTEX, entities);
-
// make sure the higher order nodes really were deleted
if(entities.size() != original_num_nodes)
return MB_FAILURE;
@@ -3224,38 +3121,17 @@
- MBEntityHandle file_set;
+
file_name = TestDir + "/mbtest1.g";
- error = MB->load_file(file_name.c_str(), file_set);
+ error = MB->load_mesh(file_name.c_str(), NULL, 0);
if (error != MB_SUCCESS)
return error;
- error = MB->delete_entities( &file_set, 1 );
- if (MB_SUCCESS != error)
- return error;
// delete all MBTRI's
- MBRange tri_sets;
- MBTag matset_tag;
- if (MB_SUCCESS == MB->tag_get_handle( MATERIAL_SET_TAG_NAME, matset_tag )) {
- error = MB->get_entities_by_type_and_tag( 0, MBENTITYSET, &matset_tag, 0, 1, tri_sets, MBInterface::UNION );
- if (MB_SUCCESS != error)
- return error;
-//MBRange users2;
-//error = dynamic_cast<MBCore*>(MB)->find_all_referencing_entities( tri_sets.front(), users2 );
-//assert(MB_SUCCESS == error);
-//users2.print();
- error = MB->delete_entities( tri_sets );
- if (MB_SUCCESS != error)
- return error;
- }
entities.clear();
error = MB->get_entities_by_type(0, MBTRI, entities);
if (MB_SUCCESS != error)
return error;
-//MBRange users;
-//error = dynamic_cast<MBCore*>(MB)->find_all_referencing_entities( entities.front(), users );
-//assert(MB_SUCCESS == error);
-//users.print();
error = MB->delete_entities(entities);
if (MB_SUCCESS != error)
return error;
Modified: MOAB/trunk/Makefile.am
===================================================================
--- MOAB/trunk/Makefile.am 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/Makefile.am 2007-09-25 16:56:03 UTC (rev 1286)
@@ -29,8 +29,7 @@
check_PROGRAMS = $(TESTS) \
kd_tree_tool \
- kd_tree_time \
- range_map_test
+ kd_tree_time
#noinst_PROGRAMS = scdseq_timing
@@ -120,8 +119,6 @@
MBMatrix3.hpp \
MBCore.cpp \
MBFactory.cpp \
- MBFileReadTool.hpp \
- MBFileReadTool.hpp \
MBGeomUtil.cpp \
MBInternals.hpp \
MBMem.hpp \
@@ -146,7 +143,6 @@
MeshTopoUtil.cpp \
PolyEntitySequence.cpp \
PolyEntitySequence.hpp \
- RangeMap.hpp \
ReadGmsh.cpp \
ReadGmsh.hpp \
ReadParallel.hpp \
@@ -305,8 +301,6 @@
file_options_test_SOURCES = FileOptions.cpp
file_options_test_CPPFLAGS = -DTEST
-range_map_test_sources = RangeMapTest.cpp RangeMap.hpp
-
# Other files to clean up (e.g. output from tests)
MOSTLYCLEANFILES = dumped_acis.sat
Modified: MOAB/trunk/MeshSetSequence.cpp
===================================================================
--- MOAB/trunk/MeshSetSequence.cpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/MeshSetSequence.cpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -49,13 +49,7 @@
// allocate storage
mSets = new unsigned char[SET_SIZE * num_entities];
-#ifdef MOAB_WITH_REFCOUNT
- mRefCount.clear();
- mRefCount.resize( num_entities, flags ? 1 : 0 );
-#else
mFreeEntities.clear();
-#endif
-
if (flags) {
mNumEntities = num_entities;
mFirstFreeIndex = -1;
@@ -66,9 +60,7 @@
man->notify_not_full( this );
mNumEntities = 0;
mFirstFreeIndex = 0;
-#ifndef MOAB_WITH_REFCOUNT
mFreeEntities.resize( mNumAllocated, true );
-#endif
for (MBEntityID i = 0; i < num_entities; ++i)
next_free(i) = i + 1;
next_free(num_entities-1) = -1;
@@ -97,11 +89,7 @@
return 0;
const MBEntityID index = mFirstFreeIndex;
-#ifndef MOAB_WITH_REFCOUNT
mFreeEntities[index] = false;
-#else
- mRefCount[index] = 1;
-#endif
mFirstFreeIndex = next_free(index);
if (mLastDeletedIndex == index)
mLastDeletedIndex = -1;
@@ -110,10 +98,8 @@
mNumEntities++;
if (mNumEntities == mNumAllocated) {
mSequenceManager->notify_full(this);
-#ifndef MOAB_WITH_REFCOUNT
std::vector<bool> empty;
mFreeEntities.swap( empty);
-#endif
}
return get_start_handle() + index;
@@ -124,12 +110,6 @@
if (!is_valid_entity(handle))
return;
const MBEntityID index = handle - get_start_handle();
-
-#ifdef MOAB_WITH_REFCOUNT
- if (get_reference_count(handle) != 1)
- return;
- decrement_reference_count(handle);
-#endif
// free any memory allocated by the MBMeshSet
deallocate_set( index );
@@ -137,17 +117,12 @@
// decerement count of valid entities
if(mNumEntities == mNumAllocated) {
mSequenceManager->notify_not_full(this);
-#ifndef MOAB_WITH_REFCOUNT
mFreeEntities.resize( mNumAllocated, false );
-#endif
}
--mNumEntities;
// mark this entity as invalid
-
-#ifndef MOAB_WITH_REFCOUNT
mFreeEntities[index] = true;
-#endif
// Add this entity to the free list.
// Free list is maintained in sorted order.
@@ -197,12 +172,7 @@
unsigned long& allocated ) const
{
used = 0;
- allocated = sizeof(*this);
-#ifdef MOAB_WITH_REFCOUNT
- allocated += mRefCount.capacity() * sizeof(unsigned);
-#else
- allocated += mFreeEntities.capacity()/8;
-#endif
+ allocated = sizeof(*this) + mFreeEntities.capacity()/8;
allocated += mNumAllocated * SET_SIZE;
for (MBEntityHandle h = get_start_handle(); h <= get_end_handle(); ++h) {
if (is_valid_entity(h)) {
@@ -531,16 +501,3 @@
number = children.size();
return result;
}
-
-#ifdef MOAB_WITH_REFCOUNT
-void MeshSetSequence::decrement_all_referenced_entities( MBEntityHandle handle, AEntityFactory* f)
-{
- if (is_valid_entity(handle))
- get_set( handle )->decrement_all_referenced_entities( f );
-}
-void MeshSetSequence::increment_all_referenced_entities( MBEntityHandle handle, AEntityFactory* f)
-{
- if (is_valid_entity(handle))
- get_set( handle )->increment_all_referenced_entities( f );
-}
-#endif
Modified: MOAB/trunk/MeshSetSequence.hpp
===================================================================
--- MOAB/trunk/MeshSetSequence.hpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/MeshSetSequence.hpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -64,10 +64,6 @@
MBErrorCode num_parents ( MBEntityHandle of, int& number, int num_hops ) const;
MBErrorCode num_children( MBEntityHandle of, int& number, int num_hops ) const;
-#ifdef MOAB_WITH_REFCOUNT
- virtual void decrement_all_referenced_entities( MBEntityHandle , AEntityFactory* );
- virtual void increment_all_referenced_entities( MBEntityHandle , AEntityFactory* );
-#endif
private:
void initialize( EntitySequenceManager* seq_man,
Modified: MOAB/trunk/PolyEntitySequence.cpp
===================================================================
--- MOAB/trunk/PolyEntitySequence.cpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/PolyEntitySequence.cpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -140,17 +140,11 @@
mNumEntities++;
if (mNumEntities == mNumAllocated) {
-#ifndef MOAB_WITH_REFCOUNT
std::vector<bool> empty;
mFreeEntities.swap( empty );
-#endif
mSequenceManager->notify_full(this);
}
-#ifndef MOAB_WITH_REFCOUNT
mFreeEntities[handle - get_start_handle()] = false;
-#else
- mRefCount[handle - get_start_handle()] = 1;
-#endif
// put the connectivity on the end of that array
polyConn.insert(polyConn.end(), conn, conn+num_conn);
@@ -188,12 +182,6 @@
// add this handle to the dead list, and zero out its connectivity
MBEntityID index = entity - mStartEntityHandle;
if (!is_valid_entity(entity)) return;
-
-#ifdef MOAB_WITH_REFCOUNT
- if (get_reference_count(entity) != 1) // only referenced by this sequence
- return;
- decrement_reference_count(entity);
-#endif
int start_index;
if (0 == index) start_index = 0;
@@ -203,11 +191,9 @@
// now add it to the dead list
mDeadEntities.push_back(entity);
-#ifndef MOAB_WITH_REFCOUNT
if (mFreeEntities.empty())
mFreeEntities.resize( mNumAllocated, false );
mFreeEntities[index] = true;
-#endif
// decrement number of entities
mNumEntities--;
@@ -223,17 +209,11 @@
unsigned long& allocated) const
{
allocated = sizeof(*this)
+ + mFreeEntities.capacity() / 8
+ polyConn.capacity() * sizeof(MBEntityHandle)
+ mLastIndex.capacity() * sizeof(int)
+ mDeadEntities.capacity() * sizeof(MBEntityHandle)
;
-
-#ifdef MOAB_WITH_REFCOUNT
- allocated += mRefCount.capacity() * sizeof(unsigned);
-#else
- allocated += mFreeEntities.capacity() / 8;
-#endif
-
used = 0;
for (MBEntityHandle h = get_start_handle(); h <= get_end_handle(); ++h)
if (is_valid_entity(h))
Deleted: MOAB/trunk/README.RefCount
===================================================================
--- MOAB/trunk/README.RefCount 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/README.RefCount 2007-09-25 16:56:03 UTC (rev 1286)
@@ -1,19 +0,0 @@
-This branch replaces the vector<bool> of valid/invalid flags in entity
-sequences with a vector<unsigned> of reference counts. A value of zero
-for an entity signifies a hole in the sequence. A valid entity has a
-reference count of at least 1, signifying that it is referenced by it's
-owning EntitySequence.
-
-This branch contains code to update reference counts for a) entities used in
-connectivity lists, b) entities contained in sets, c) sets referenced by
-parent/child links, d) downward adjacencies, and e) entities referenced in
-handle-type tag data. Additionally, this branch contains enhancements to
-several existing algorithms that benefit from the reference count, including
-entity deletion, higher-order conversion, merging, etc.
-
-MBTest fails due to one or more bugs while deleting entity sets. The high-level
-deletion code decrmenents reference counts for contained and parent/child
-entities. However, as part of cleaning up adjacencies, updating bi-directional
-parent/child links, etc. the low-level deletion code clears the set contents,
-etc. This results in the reference count to be decremented a *second* time.
-
Deleted: MOAB/trunk/RangeMap.hpp
===================================================================
--- MOAB/trunk/RangeMap.hpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/RangeMap.hpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -1,199 +0,0 @@
-/*
- * MOAB, a Mesh-Oriented datABase, is a software component for creating,
- * storing and accessing finite element mesh data.
- *
- * Copyright 2004 Sandia Corporation. Under the terms of Contract
- * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government
- * retains certain rights in this software.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- */
-
-/**\file RangeMap.hpp
- *\author Jason Kraftcheck (kraftche at cae.wisc.edu)
- *\date 2007-04-25
- */
-
-#ifndef RANGE_MAP_HPP
-#define RANGE_MAP_HPP
-
-#include <vector>
-#include <algorithm>
-
-/**\brief Map ranges of values
- *
- * This class provides a map between ranges of values, such as
- * a map between file IDs and MBEntityHandles. It is intended
- * for use in situations where there are relatively few insertions
- * of large contiguous ranges of values.
- */
-template <typename KeyType, typename ValType, ValType NullVal = 0>
-class RangeMap
-{
-public:
- struct Range {
- KeyType begin, count;
- ValType value;
- bool operator<( const Range& other ) const
- { return begin + count <= other.begin; } // equal if overlapping!
- };
- typedef typename std::vector<Range> RangeList;
- typedef typename RangeList::const_iterator iterator;
-
- /**\brief Insert mapping between range of keys and range of values
- *
- * Insert mapping from [first_key, first_key+count) to [first_val, first_val+count)
- *
- * Input range of keys many not overlap any other input range. If it does overlap
- * an existing range, false is returned and the internal map is not changed.
- */
- inline iterator insert( KeyType first_key, ValType first_val, KeyType count );
-
- /** Find the value corresponding to the specified key. Returns NullVal if not found */
- inline ValType find( KeyType key ) const;
-
- /** Remove a block of values */
- inline iterator erase( KeyType beg, KeyType count );
-
- inline unsigned num_ranges() const { return data.size(); }
-
- inline iterator begin() const { return data.begin(); }
- inline iterator end() const { return data.end(); }
- inline iterator lower_bound( KeyType key ) const
- {
- Range b = { key, 1, NullVal };
- return std::lower_bound( begin(), end(), b );
- }
- inline iterator upper_bound( KeyType key ) const
- {
- Range b = { key, 1, NullVal };
- return std::upper_bound( begin(), end(), b );
- }
- inline std::pair<iterator,iterator>
- equal_range( KeyType key ) const
- {
- Range b = { key, 1, NullVal };
- return std::equal_range( begin(), end(), b );
- }
-
- inline void clear() { data.clear(); }
-
-protected:
- RangeList data;
-};
-
-template <typename KeyType, typename ValType, ValType NullVal>
-inline typename RangeMap<KeyType,ValType,NullVal>::iterator
-RangeMap<KeyType,ValType,NullVal>::insert( KeyType first_key, ValType first_val, KeyType count )
-{
- Range block = { first_key, count, first_val };
- typename RangeList::iterator i = std::lower_bound( data.begin(), data.end(), block );
-
- if (i == data.end()) {
- if (i != data.begin()) {
- --i;
- if (i->begin + i->count == first_key &&
- i->value + i->count == first_val) {
- i->count += count;
- return i;
- }
- }
- data.push_back( block );
- return data.end() - 1;
- }
-
- if (i->begin < first_key + count)
- return data.end();
-
- if (i->begin == first_key + count &&
- i->value == first_val + count) {
- i->begin = first_key;
- i->value = first_val;
- i->count += count;
- if (i != data.begin()) {
- count = i->count;
- --i;
- if (i->begin + i->count == first_key &&
- i->value + i->count == first_val) {
- i->count += count;
- ++i;
- i = data.erase(i);
- --i;
- }
- }
- return i;
- }
-
- if (i != data.begin()) {
- --i;
- if (i->begin + i->count == first_key &&
- i->value + i->count == first_val) {
- i->count += count;
- return i;
- }
- ++i;
- }
-
- return data.insert( i, block );
-}
-
-
-
-template <typename KeyType, typename ValType, ValType NullVal> inline
-ValType RangeMap<KeyType,ValType,NullVal>::find( KeyType key ) const
-{
- Range search = { key, 1, NullVal };
- typename RangeList::const_iterator i = std::lower_bound( data.begin(), data.end(), search );
- if (i == data.end() || i->begin > key)
- return NullVal;
-
- return i->value + key - i->begin;
-}
-
-template <typename KeyType, typename ValType, ValType NullVal>
-inline typename RangeMap<KeyType,ValType,NullVal>::iterator
-RangeMap<KeyType,ValType,NullVal>::erase( KeyType key, KeyType count )
-{
- Range search = { key, 1, NullVal };
- typename RangeList::iterator i, j;
- i = std::lower_bound( data.begin(), data.end(), search );
-
- if (i == data.end())
- return i;
-
- if (key > i->begin) {
- KeyType offset = key - i->begin;
- // special case - split existing entry
- if((offset + count) < i->count) {
- Range ins = { i->begin, offset, i->value };
- offset += count;
- i->begin += offset;
- i->value += offset;
- i->count -= offset;
- return data.insert( i, ins ) + 1;
- }
- // otherwise remove the latter part of i
- i->count = offset;
- ++i;
- }
-
- // remove any entries entirely convered by the input range
- for (j = i; j != data.end() && (j->begin + j->count) <= (key + count); ++j);
- i = data.erase(i,j);
-
- // remove beginning of last block
- if (i != data.end() && (key + count) >= i->begin) {
- KeyType offset = key + count - i->begin;
- i->begin += offset;
- i->value += offset;
- i->count -= offset;
- }
-
- return i;
-}
-
-#endif
Deleted: MOAB/trunk/RangeMapTest.cpp
===================================================================
--- MOAB/trunk/RangeMapTest.cpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/RangeMapTest.cpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -1,143 +0,0 @@
-#include "RangeMap.hpp"
-#include <iostream>
-#include <iomanip>
-#include <stdio.h>
-#include <stdlib.h>
-
-RangeMap<long,long,0> mapInstance;
-
-
-bool insert( std::vector<long>& values );
-bool verify( std::vector<long>& values );
-bool print( std::vector<long>& values );
-bool clear( std::vector<long>& values );
-bool help();
-
-bool do_command( char* cmd )
-{
- std::vector<long> values;
- char *ptr, *end;
- const char space[] = " \t\r\n";
- char c = cmd[0];
- ++cmd;
-
- for (ptr = strtok( cmd, space ); ptr; ptr = strtok( 0, space )) {
- long val = strtol( ptr, &end, 0 );
- if (*end) {
- std::cerr << "Invalid integer value: " << ptr << std::endl;
- return false;
- }
- values.push_back( val );
- }
-
- switch (c) {
- case 'i': return insert( values );
- case 'v': return verify( values );
- case 'p': return print( values );
- case 'c': return clear( values );
- case 'h': return help( );
- default:
- std::cerr << "Unknown command: " << c << std::endl;
- return false;
- }
-}
-
-
-bool insert( std::vector<long>& values )
-{
- if (values.size() % 3) {
- std::cerr << "Invalid arguments for insertion. "
- "Insertion requires tuples of three values: "
- "{start_key,start_val,count}" << std::endl;
- return false;
- }
- for (unsigned i = 0; i < values.size(); i += 3)
- if (mapInstance.end() == mapInstance.insert( values[i], values[i+1], values[i+2] ))
- std::cout << "Insertion of {" << values[i] << ", "
- << values[i+1] << ", "
- << values[i+2] << "} FAILED" << std::endl;
- return true;
-}
-
-bool clear( std::vector<long>& values )
-{
- if (values.size() % 2) {
- std::cerr << "(c)lear command expects ranges of values (or no values)" << std::endl;
- return false;
- }
-
- if(values.empty()) {
- mapInstance.clear();
- return true;
- }
-
- for (unsigned i = 0; i < values.size(); i += 2)
- mapInstance.erase( values[i], values[i+1] );
-
- return true;
-}
-
-bool print( std::vector<long>& values )
-{
- const int W = 20;
- if (values.empty()) {
- std::cout << std::setw(W) << "Start Key"
- << std::setw(W) << "Start Val"
- << std::setw(W) << "Count"
- << std::endl;
- RangeMap<long,long,0>::iterator i = mapInstance.begin();
- for (; i != mapInstance.end(); ++i)
- std::cout << std::setw(W) << i->begin
- << std::setw(W) << i->value
- << std::setw(W) << i->count
- << std::endl;
- }
- else {
- for (unsigned i = 0; i < values.size(); ++i)
- std::cout << std::setw(W) << values[i] << "->"
- << std::setw(W) << mapInstance.find(values[i]) << std::endl;
- }
- return true;
-}
-
-bool verify( std::vector<long>& values )
-{
- if (values.size() % 3) {
- std::cerr << "Invalid arguments for insertion. "
- "Insertion requires tuples of three values: "
- "{start_key,start_val,count}" << std::endl;
- return false;
- }
-
- bool result = true;
- RangeMap<long,long,0>::iterator i = mapInstance.begin();
- std::vector<long>::iterator j = values.begin();
- for (; i != mapInstance.end(); ++i)
- if (j == values.end() ||
- i->begin != *j++ ||
- i->value != *j++ ||
- i->count != *j++)
- result = false;
-
- return result && j == values.end();
-}
-
-bool help()
-{
- std::cout << "Commands: i p c v h" << std::endl
- << " i - insert list of values " << std::endl
- << " p - print entire map or lookup specified values" << std::endl
- << " c - clear map" << std::endl
- << " v - verify map contents" << std::endl
- << " h - this help" << std::endl;
- return true;
-}
-
-int main() {
- char buffer[1024];
- bool exit_val = 0;
- while (fgets(buffer, sizeof(buffer), stdin))
- exit_val += !do_command(buffer);
- return exit_val;
-}
-
Modified: MOAB/trunk/ReadGmsh.cpp
===================================================================
--- MOAB/trunk/ReadGmsh.cpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/ReadGmsh.cpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -399,8 +399,6 @@
{
memcpy( conn_array, &connectivity[0], connectivity.size() * sizeof(MBEntityHandle) );
}
-
- readMeshIface->increment_reference_count( conn_array, num_elem * node_per_elem );
// Store element IDs
result = mdbImpl->tag_set_data( globalId, elements, &elem_ids[0] );
Modified: MOAB/trunk/ReadHDF5.cpp
===================================================================
--- MOAB/trunk/ReadHDF5.cpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/ReadHDF5.cpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -429,9 +429,7 @@
return MB_FAILURE;
}
- rval = convert_id_to_handle( nodeSet, array, (size_t)nodes_per_elem*count );
- if (MB_SUCCESS == rval)
- readUtil->increment_reference_count( array, (size_t)nodes_per_elem*count );
+ rval = convert_id_to_handle( nodeSet, array, (size_t)(nodes_per_elem*count) );
return rval;
}
@@ -523,10 +521,7 @@
return MB_FAILURE;
}
- rval = convert_id_to_handle( conn_array, (size_t)data_len );
- if (MB_SUCCESS == rval)
- readUtil->increment_reference_count( conn_array, (size_t)data_len );
- return rval;
+ return convert_id_to_handle( conn_array, (size_t)data_len );
}
template <typename T>
Modified: MOAB/trunk/ReadNCDF.cpp
===================================================================
--- MOAB/trunk/ReadNCDF.cpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/ReadNCDF.cpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -905,7 +905,6 @@
nodesInLoadedBlocks[tmp_ptr[i]] = 1;
conn[i] = static_cast<MBEntityHandle>(tmp_ptr[i]) + vertexOffset;
}
- readMeshIface->increment_reference_count( conn, number_nodes );
readMeshIface->update_adjacencies((*this_it).startMBId, (*this_it).numElements,
ExoIIUtil::VerticesPerElement[(*this_it).elemType], conn);
Modified: MOAB/trunk/ReadSTL.cpp
===================================================================
--- MOAB/trunk/ReadSTL.cpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/ReadSTL.cpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -218,8 +218,6 @@
*connectivity = vertex_map[i->points[2]]; ++connectivity;
}
- readMeshIface->increment_reference_count( connectivity, 3*triangles.size() );
-
return MB_SUCCESS;
}
Modified: MOAB/trunk/ReadVtk.cpp
===================================================================
--- MOAB/trunk/ReadVtk.cpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/ReadVtk.cpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -573,8 +573,6 @@
}
}
- readMeshIface->increment_reference_count( conn_array, size[1] - size[0] );
-
return MB_SUCCESS;
}
@@ -659,11 +657,11 @@
MBEntityHandle* conn_array;
int* index_array = 0;
- long conn_len = 0;
if (type == MBPOLYGON)
{
// Calculate total length of connectivity list
std::vector<long>::iterator conn_iter2 = conn_iter;
+ long conn_len = 0;
for (i = 0; i < num_elem; ++i)
{
conn_len += *conn_iter2;
@@ -676,7 +674,6 @@
}
else
{
- conn_len = num_elem * num_vtx;
result = allocate_elements( num_elem, num_vtx, type, start_handle,
conn_array, elem_list );
}
@@ -735,10 +732,8 @@
conn_array += num_vtx;
}
+ }
- readMeshIface->increment_reference_count( conn_array, conn_len );
- }
-
return MB_SUCCESS;
}
@@ -798,8 +793,6 @@
*conn_array = index + corners[j] + first_vtx;
}
-
- readMeshIface->increment_reference_count( conn_array, vert_per_elem * num_elems );
return MB_SUCCESS;
}
Modified: MOAB/trunk/TagServer.cpp
===================================================================
--- MOAB/trunk/TagServer.cpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/TagServer.cpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -591,16 +591,6 @@
return MB_SUCCESS;
}
-MBErrorCode TagServer::get_tags(MBDataType type, std::vector<MBTag> &all_tags)
-{
- for (int i = 0; i < MB_TAG_LAST+1; ++i)
- for (MBTagId j = 0; j < mTagTable[i].size(); ++j)
- if (mTagTable[i][j].is_valid() && mTagTable[i][j].get_data_type() == type)
- all_tags.push_back( TAG_HANDLE_FROM_ID( j + 1, (MBTagType)i ) );
-
- return MB_SUCCESS;
-}
-
MBErrorCode TagServer::get_tags(const MBEntityHandle entity, std::vector<MBTag> &all_tags)
{
MBErrorCode result = MB_SUCCESS;
Modified: MOAB/trunk/TagServer.hpp
===================================================================
--- MOAB/trunk/TagServer.hpp 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/TagServer.hpp 2007-09-25 16:56:03 UTC (rev 1286)
@@ -255,9 +255,6 @@
//! get all the tags which have been defined
MBErrorCode get_tags(std::vector<MBTag> &all_tags);
- //! get all tags that store a specified data type
- MBErrorCode get_tags( MBDataType type, std::vector<MBTag>& tags );
-
//! get the default value for a given tag
MBErrorCode get_default_data(const MBTag tag_handle, void *data);
Modified: MOAB/trunk/configure.in
===================================================================
--- MOAB/trunk/configure.in 2007-09-25 16:45:54 UTC (rev 1285)
+++ MOAB/trunk/configure.in 2007-09-25 16:56:03 UTC (rev 1286)
@@ -47,16 +47,7 @@
fi
AC_DEFINE_UNQUOTED(MB_VERSION_STRING,"${VERSION_STRING}",[MOAB Version String])
-################################################################################
-# Debugging Features
-################################################################################
-AC_MSG_CHECKING([if reference counting is enabled])
-AC_ARG_ENABLE([refcounts],
- [AC_HELP_STRING([enable-refcounts],[Enable reference counting])],
- [DEFINES="$DEFINES -DMOAB_WITH_REFCOUNT"; AC_MSG_RESULT([yes])],
- [AC_MSG_RESULT([no])])
-
################################################################################
# Extract libtool config
################################################################################
More information about the moab-dev
mailing list