[MOAB-dev] r1521 - MOAB/trunk
kraftche at mcs.anl.gov
kraftche at mcs.anl.gov
Mon Jan 14 13:50:39 CST 2008
Author: kraftche
Date: 2008-01-14 13:50:39 -0600 (Mon, 14 Jan 2008)
New Revision: 1521
Added:
MOAB/trunk/TagCompare.hpp
Modified:
MOAB/trunk/SequenceManager.cpp
MOAB/trunk/SequenceManager.hpp
MOAB/trunk/SparseTagCollections.cpp
MOAB/trunk/SparseTagCollections.hpp
MOAB/trunk/TagServer.cpp
MOAB/trunk/TagServer.hpp
MOAB/trunk/VarLenTag.hpp
Log:
- Add new tag comparison code that
a) works for variable-length tags
b) has correct behavior for positive/negative 0.0
c) is faster for some tag searches
- Call new tag comparison code for sparse and dense tags
- Update low-level tag APIs to support new tag comparison code
and searching for variable-length tag values.
Modified: MOAB/trunk/SequenceManager.cpp
===================================================================
--- MOAB/trunk/SequenceManager.cpp 2008-01-14 19:48:15 UTC (rev 1520)
+++ MOAB/trunk/SequenceManager.cpp 2008-01-14 19:50:39 UTC (rev 1521)
@@ -7,6 +7,7 @@
#include "HomXform.hpp"
#include "PolyElementSeq.hpp"
#include "MBSysUtil.hpp"
+#include "TagCompare.hpp"
#include <assert.h>
#include <new>
@@ -927,9 +928,11 @@
}
MBErrorCode SequenceManager::get_entities_with_tag_value( MBTagId id,
+ const TagInfo& tag_info,
MBEntityType type,
MBRange& entities_out,
- const void* value ) const
+ const void* value,
+ int size ) const
{
if (id >= tagSizes.size() || !tagSizes[id])
return MB_TAG_NOT_FOUND;
@@ -938,10 +941,10 @@
const TypeSequenceManager& map = entity_map( type );
for (TypeSequenceManager::const_iterator i = map.begin(); i != map.end(); ++i) {
if (const void* data = (*i)->data()->get_tag_data(id)) {
- const char* bytes = reinterpret_cast<const char*>(data);
- for (MBEntityHandle h = (*i)->start_handle(); h <= (*i)->end_handle(); ++h)
- if (!memcmp( bytes + tagSizes[id] * (h - (*i)->data()->start_handle()), value, tagSizes[id] ))
- insert = entities_out.insert( insert, h, h );
+ ByteArrayIterator start( (*i)->data()->start_handle(), data, tag_info );
+ ByteArrayIterator end( (*i)->end_handle() + 1, 0, 0 );
+ start += (*i)->start_handle() - (*i)->data()->start_handle();
+ find_tag_values_equal( tag_info, value, size, start, end, entities_out );
}
}
@@ -950,9 +953,11 @@
MBErrorCode SequenceManager::get_entities_with_tag_value( const MBRange& range,
MBTagId id,
+ const TagInfo& tag_info,
MBEntityType type,
MBRange& entities_out,
- const void* value ) const
+ const void* value,
+ int size ) const
{
MBErrorCode rval;
if (id >= tagSizes.size() || !tagSizes[id])
@@ -975,11 +980,10 @@
const MBEntityHandle finish = std::min( p->second, seq->end_handle() );
const void* tag_array = seq->data()->get_tag_data( id );
if (tag_array) {
- const char* tag_data = reinterpret_cast<const char*>(tag_array);
- for (MBEntityHandle h = start; h <= finish; ++h) {
- if (!memcmp( tag_data + tagSizes[id] * (h - seq->data()->start_handle()), value, tagSizes[id] ))
- insert = entities_out.insert( insert, h, h );
- }
+ ByteArrayIterator start( seq->data()->start_handle(), tag_array, tag_info );
+ ByteArrayIterator end( seq->end_handle() + 1, 0, 0 );
+ start += seq->start_handle() - seq->data()->start_handle();
+ find_tag_values_equal( tag_info, value, size, start, end, entities_out );
}
start = finish + 1;
}
Modified: MOAB/trunk/SequenceManager.hpp
===================================================================
--- MOAB/trunk/SequenceManager.hpp 2008-01-14 19:48:15 UTC (rev 1520)
+++ MOAB/trunk/SequenceManager.hpp 2008-01-14 19:50:39 UTC (rev 1521)
@@ -3,6 +3,7 @@
#include "TypeSequenceManager.hpp"
#include "MBHandleUtils.hpp"
+#include "TagInfo.hpp"
class HomCoord;
class TagServer;
@@ -154,14 +155,18 @@
int& result ) const;
MBErrorCode get_entities_with_tag_value( MBTagId id,
+ const TagInfo& tag_info,
MBEntityType type,
MBRange& entities_out,
- const void* value ) const;
+ const void* value,
+ int value_size ) const;
MBErrorCode get_entities_with_tag_value( const MBRange& range,
MBTagId id,
+ const TagInfo& tag_info,
MBEntityType type,
MBRange& entities_out,
- const void* value ) const;
+ const void* value,
+ int value_size ) const;
MBErrorCode get_tag_memory_use( MBTagId id,
unsigned long& total,
Modified: MOAB/trunk/SparseTagCollections.cpp
===================================================================
--- MOAB/trunk/SparseTagCollections.cpp 2008-01-14 19:48:15 UTC (rev 1520)
+++ MOAB/trunk/SparseTagCollections.cpp 2008-01-14 19:50:39 UTC (rev 1521)
@@ -32,6 +32,7 @@
#include "SparseTagCollections.hpp"
#include "MBRange.hpp"
+#include "TagCompare.hpp"
/*
SparseTagSuperCollection functions -----------------------------
@@ -158,27 +159,38 @@
}
//! gets all entity handles that match a type and tag
-MBErrorCode SparseTagSuperCollection::get_entities_with_tag_value(const MBTagId tag_handle, const MBEntityType type,
- MBRange &entities, const void* tag_value)
+MBErrorCode SparseTagSuperCollection::get_entities_with_tag_value(
+ const MBTagId tag_handle,
+ const TagInfo& tag_info,
+ const MBEntityType type,
+ MBRange &entities,
+ const void* tag_value,
+ int value_size)
{
SparseTagCollection* coll = get_collection(tag_handle);
if (!coll)
return MB_TAG_NOT_FOUND;
- return coll->get_entities_with_tag_value(type, entities, tag_value);
+ return coll->get_entities_with_tag_value(tag_info, type, entities, tag_value, value_size);
}
//! gets all entity handles that match a type and tag
-MBErrorCode SparseTagSuperCollection::get_entities_with_tag_value(const MBRange &range,
- const MBTagId tag_handle, const MBEntityType type,
- MBRange &entities, const void* tag_value)
+MBErrorCode SparseTagSuperCollection::get_entities_with_tag_value(
+ const MBRange &range,
+ const MBTagId tag_handle,
+ const TagInfo& tag_info,
+ const MBEntityType type,
+ MBRange &entities,
+ const void* tag_value,
+ int value_size)
{
SparseTagCollection* coll = get_collection(tag_handle);
if (!coll)
return MB_TAG_NOT_FOUND;
MBRange dum_range;
- MBErrorCode result = coll->get_entities_with_tag_value(type, dum_range, tag_value);
+ MBErrorCode result = coll->get_entities_with_tag_value(
+ tag_info, type, dum_range, tag_value, value_size);
// do this the hard way to preserve order in the vector
std::set_intersection(range.begin(), range.end(),
@@ -355,29 +367,22 @@
//! gets all entity handles that match a type, tag and tag value
-MBErrorCode SparseTagCollection::get_entities_with_tag_value(MBEntityType type,
- MBRange &entities, const void* tag_value)
+MBErrorCode SparseTagCollection::get_entities_with_tag_value(
+ const TagInfo& tag_info,
+ MBEntityType type,
+ MBRange &entities,
+ const void* tag_value,
+ int value_size)
{
- std::map<MBEntityHandle, void*>::iterator iter;
-
- for(iter = mData.begin(); iter != mData.end(); ++iter)
- {
- if(TYPE_FROM_HANDLE(iter->first) == type) {
-#ifndef NDEBUG
- MBEntityHandle this_ent = iter->first;
- void *this_tag = iter->second;
- // coupla meaningless statements to get rid of compiler warnings
- if (this_ent);
- if (this_tag);
-#endif
- if( memcmp( iter->second, tag_value, mDataSize ) == 0)
- entities.insert(iter->first);
- }
- }
-
+ std::map<MBEntityHandle, void*>::iterator iter, end;
+ int junk;
+ iter = mData.lower_bound( CREATE_HANDLE( type, MB_START_ID, junk ) );
+ end = mData.upper_bound( CREATE_HANDLE( type, MB_END_ID, junk ) );
+ find_tag_values_equal( tag_info, tag_value, value_size, iter, end, entities );
return MB_SUCCESS;
}
+
Modified: MOAB/trunk/SparseTagCollections.hpp
===================================================================
--- MOAB/trunk/SparseTagCollections.hpp 2008-01-14 19:48:15 UTC (rev 1520)
+++ MOAB/trunk/SparseTagCollections.hpp 2008-01-14 19:50:39 UTC (rev 1521)
@@ -45,6 +45,7 @@
#include "MBTypes.h"
#include "MBInternals.hpp"
#include "MBRange.hpp"
+#include "TagInfo.hpp"
#define get_collection( A ) ((A) < mDataTags.size() ? mDataTags[(A)] : 0)
@@ -100,9 +101,11 @@
MBErrorCode get_entities(MBRange &entities) const;
//! gets all entity handles that match a type, tag, tag_value
- MBErrorCode get_entities_with_tag_value(MBEntityType type,
+ MBErrorCode get_entities_with_tag_value( const TagInfo& info,
+ MBEntityType type,
MBRange &entities,
- const void* tag_value);
+ const void* tag_value,
+ int value_size);
//! if this collection contains this entity, return true, otherwise false
bool contains(const MBEntityHandle entity) const;
@@ -189,15 +192,21 @@
std::vector<MBTag> &all_tags);
//! gets all entity handles that match a tag
- MBErrorCode get_entities_with_tag_value(const MBTagId tag_handle, const MBEntityType type,
+ MBErrorCode get_entities_with_tag_value( const MBTagId tag_handle,
+ const TagInfo& tag_info,
+ const MBEntityType type,
MBRange &entities,
- const void* tag_value);
+ const void* tag_value,
+ int value_size);
//! gets all entity handles that match a tag
- MBErrorCode get_entities_with_tag_value(const MBRange &range,
- const MBTagId tag_handle, const MBEntityType type,
+ MBErrorCode get_entities_with_tag_value( const MBRange &range,
+ const MBTagId tag_handle,
+ const TagInfo& tag_info,
+ const MBEntityType type,
MBRange &entities,
- const void* tag_value);
+ const void* tag_value,
+ int value_size);
//! gets the number of entities that match a tag
MBErrorCode get_number_entities(const MBTagId tag_handle, const MBEntityType type, int& num_ent);
Added: MOAB/trunk/TagCompare.hpp
===================================================================
--- MOAB/trunk/TagCompare.hpp (rev 0)
+++ MOAB/trunk/TagCompare.hpp 2008-01-14 19:50:39 UTC (rev 1521)
@@ -0,0 +1,358 @@
+#ifndef TAG_COMPARE_HPP
+#define TAG_COMPARE_HPP
+
+#include "TagInfo.hpp"
+#include "VarLenTag.hpp"
+
+/* OPAQUE FUNCTORS */
+
+/** Test fixed-length opaque tags for equality */
+class TagBytesEqual {
+ private:
+ const void* value;
+ int size;
+ public:
+ TagBytesEqual( const void* v, int s ) : value(v), size(s) {}
+ bool operator()( const void* data ) const
+ { return !memcmp(value, data, size); }
+};
+/** Test if fixed-length opaque tag values are less than a value */
+class TagBytesLess {
+ private:
+ const void* value;
+ int size;
+ public:
+ TagBytesLess( const void* v, int s ) : value(v), size(s) {}
+ bool operator()( const void* data ) const
+ { return 0 < memcmp(value, data, size); }
+};
+/** Test variable-length opaque tags for equality */
+class TagVarBytesEqual {
+ private:
+ const void* value;
+ int size;
+ public:
+ TagVarBytesEqual( const void* v, int s ) : value(v), size(s) {}
+ bool operator()( const void* data ) const {
+ const VarLenTag* vdata = reinterpret_cast<const VarLenTag*>(data);
+ return (int)vdata->size() == size && !memcmp(value, vdata->data(), size);
+ }
+};
+/** Test if variable-length opaque tag values are less than a value */
+class TagVarBytesLess {
+ private:
+ const void* value;
+ int size;
+ public:
+ TagVarBytesLess( const void* v, int s ) : value(v), size(s) {}
+ bool operator()( const void* data ) const {
+ const VarLenTag* vdata = reinterpret_cast<const VarLenTag*>(data);
+ if ((int)vdata->size() < size)
+ return 0 <= memcmp( vdata->data(), value, vdata->size() );
+ else
+ return 0 < memcmp( vdata->data(), value, size );
+ }
+};
+
+
+/* TEMPLATE FUNCTORS */
+
+
+/** Compare fixed-length tags containing a known data type */
+template <typename T>
+class TagTypeEqual {
+ private:
+ const T* value;
+ int size;
+ public:
+ TagTypeEqual( const void* v, int s )
+ : value(reinterpret_cast<const T*>(v)),
+ size(s/sizeof(T))
+ {}
+
+ bool operator()( const void* data ) const {
+ const T* ddata = reinterpret_cast<const T*>(data);
+ for (int i = 0; i < size; ++i)
+ if (value[i] != ddata[i])
+ return false;
+ return true;
+ }
+};
+
+/** Compare fixed-length tags containing a known data type */
+template <typename T>
+class TagTypeLess {
+ private:
+ const T* value;
+ int size;
+ public:
+ TagTypeLess( const void* v, int s )
+ : value(reinterpret_cast<const T*>(v)),
+ size(s/sizeof(T))
+ {}
+
+ bool operator()( const void* data ) const {
+ const T* ddata = reinterpret_cast<const T*>(data);
+ for (int i = 0; i < size; ++i)
+ if (value[i] <= ddata[i])
+ return false;
+ return true;
+ }
+};
+
+/** Compare single-value tags containing a known data type
+ * Optimization of TagTypeEqual for 1-value case.
+ */
+template <typename T>
+class TagOneTypeEqual {
+ private:
+ T value;
+ int size;
+ public:
+ TagOneTypeEqual( const void* v )
+ : value(*reinterpret_cast<const T*>(v))
+ {}
+
+ bool operator()( const void* data ) const {
+ const T* ddata = reinterpret_cast<const T*>(data);
+ return *ddata == value;
+ }
+};
+
+/** Compare single-value tags containing a known data type
+ * Optimization of TagTypeLess for 1-value case.
+ */
+template <typename T>
+class TagOneTypeLess {
+ private:
+ T value;
+ int size;
+ public:
+ TagOneTypeLess( const void* v )
+ : value(*reinterpret_cast<const T*>(v))
+ {}
+
+ bool operator()( const void* data ) const {
+ const T* ddata = reinterpret_cast<const T*>(data);
+ return *ddata < value;
+ }
+};
+
+/** Compare variable-length tags containing a known data type */
+template <typename T>
+class TagVarTypeEqual
+{
+ private:
+ const T* value;
+ int size;
+ public:
+ TagVarTypeEqual( const void* v, int s )
+ : value(reinterpret_cast<const T*>(v)),
+ size(s/sizeof(T))
+ {}
+
+ bool operator()( const void* data ) const {
+ const VarLenTag* vdata = reinterpret_cast<const VarLenTag*>(data);
+ if (vdata->size() != size * sizeof(T))
+ return false;
+ const T* ddata = reinterpret_cast<const T*>(vdata->data());
+ for (int i = 0; i < size; ++i)
+ if (value[i] != ddata[i])
+ return false;
+ return true;
+ }
+};
+
+/** Compare variable-length tags containing a known data type */
+template <typename T>
+class TagVarTypeLess
+{
+ private:
+ const T* value;
+ int size;
+ public:
+ TagVarTypeLess( const void* v, int s )
+ : value(reinterpret_cast<const T*>(v)),
+ size(s/sizeof(T))
+ {}
+ bool operator()( const void* data ) const {
+ const VarLenTag* vdata = reinterpret_cast<const VarLenTag*>(data);
+ const T* ddata = reinterpret_cast<const T*>(vdata->data());
+ if ((int)vdata->size() < sizeof(T)*size) {
+ for (int i = 0; i < vdata->size()/sizeof(T); ++i)
+ if (value[i] < ddata[i])
+ return false;
+ }
+ else {
+ for (int i = 0; i < vdata->size()/sizeof(T); ++i)
+ if (value[i] <= ddata[i])
+ return false;
+ }
+ return true;
+ }
+};
+
+/* TYPE FUNCTORS */
+
+typedef TagBytesEqual TagIntsEqual;
+typedef TagVarBytesEqual TagVarIntsEqual;
+typedef TagTypeLess <int> TagIntsLess;
+typedef TagVarTypeLess <int> TagVarIntsLess;
+typedef TagOneTypeEqual<int> TagOneIntEqual;
+typedef TagOneTypeLess <int> TagOneIntLess;
+
+typedef TagBytesEqual TagHandlesEqual;
+typedef TagVarBytesEqual TagVarHandlesEqual;
+typedef TagTypeLess <MBEntityHandle> TagHandlesLess;
+typedef TagVarTypeLess <MBEntityHandle> TagVarHandlesLess;
+typedef TagOneTypeEqual<MBEntityHandle> TagOneHandleEqual;
+typedef TagOneTypeLess <MBEntityHandle> TagOneHandleLess;
+
+typedef TagTypeEqual <double> TagDoublesEqual;
+typedef TagVarTypeEqual<double> TagVarDoublesEqual;
+typedef TagTypeLess <double> TagDoublesLess;
+typedef TagVarTypeLess <double> TagVarDoublesLess;
+typedef TagOneTypeEqual<double> TagOneDoubleEqual;
+typedef TagOneTypeLess <double> TagOneDoubleLess;
+
+/* SEARCHING */
+
+template <class Functor,
+ class IteratorType>
+void find_tag_values( Functor compare,
+ IteratorType begin,
+ IteratorType end,
+ MBRange& results )
+{
+ MBRange::iterator insert = results.begin();
+ for (IteratorType i = begin; i != end; ++i)
+ if (compare( i->second ))
+ insert = results.insert( insert, i->first, i->first );
+}
+
+template <class Functor,
+ class IteratorType>
+void find_tag_values( Functor compare,
+ IteratorType begin,
+ IteratorType end,
+ std::vector<MBEntityHandle>& results )
+{
+ MBRange::iterator insert = results.begin();
+ for (IteratorType i = begin; i != end; ++i)
+ if (compare( i->second ))
+ results.push_back( i->first );
+}
+
+/** Find all entities for which a tag has a specific value
+ *\param IteratorType : an iterator that has map behavior:
+ * the value of 'first' is the entity handle.
+ * the value of 'second' is a pointer to the tag data.
+ *\param ContainerType : std::vector<MBEntityHandle> or MBRange
+ */
+template <class IteratorType, class ContainerType>
+void find_tag_values_equal( const TagInfo& tag_info,
+ const void* value,
+ int size,
+ IteratorType begin,
+ IteratorType end,
+ ContainerType& results )
+{
+ switch (tag_info.get_data_type()) {
+ case MB_TYPE_INTEGER:
+ switch (tag_info.get_size()) {
+ case MB_VARIABLE_LENGTH:
+ find_tag_values( TagVarIntsEqual( value, size ), begin, end, results );
+ break;
+ case sizeof(int):
+ find_tag_values( TagOneIntEqual( value ), begin, end, results );
+ break;
+ default:
+ find_tag_values( TagIntsEqual( value, size ), begin, end, results );
+ break;
+ }
+ break;
+
+ case MB_TYPE_DOUBLE:
+ switch (tag_info.get_size()) {
+ case MB_VARIABLE_LENGTH:
+ find_tag_values( TagVarDoublesEqual( value, size ), begin, end, results );
+ break;
+ case sizeof(double):
+ find_tag_values( TagOneDoubleEqual( value ), begin, end, results );
+ break;
+ default:
+ find_tag_values( TagDoublesEqual( value, size ), begin, end, results );
+ break;
+ }
+ break;
+
+ case MB_TYPE_HANDLE:
+ switch (tag_info.get_size()) {
+ case MB_VARIABLE_LENGTH:
+ find_tag_values( TagVarHandlesEqual( value, size ), begin, end, results );
+ break;
+ case sizeof(MBEntityHandle):
+ find_tag_values( TagOneHandleEqual( value ), begin, end, results );
+ break;
+ default:
+ find_tag_values( TagHandlesEqual( value, size ), begin, end, results );
+ break;
+ }
+ break;
+
+ default:
+ if (tag_info.get_size() == MB_VARIABLE_LENGTH)
+ find_tag_values( TagVarBytesEqual( value, size ), begin, end, results );
+ else
+ find_tag_values( TagBytesEqual( value, size ), begin, end, results );
+ break;
+ }
+}
+
+/** Iterator to use in find_tag_values_equal for arrays of data */
+class ByteArrayIterator
+{
+ private:
+ size_t step;
+ typedef std::pair<MBEntityHandle, const char*> data_type;
+ data_type data;
+ public:
+ ByteArrayIterator( MBEntityHandle start_handle,
+ const void* data_array,
+ size_t tag_size )
+ : step(tag_size),
+ data(start_handle, reinterpret_cast<const char*>(data_array))
+
+ {}
+ ByteArrayIterator( MBEntityHandle start_handle,
+ const void* data_array,
+ const TagInfo& tag_info )
+ : step(tag_info.get_size() == MB_VARIABLE_LENGTH ? sizeof(VarLenTag) : tag_info.get_size()),
+ data(start_handle, reinterpret_cast<const char*>(data_array))
+ {}
+ bool operator==( const ByteArrayIterator& other ) const
+ { return data.first == other.data.first; }
+ bool operator!=( const ByteArrayIterator& other ) const
+ { return data.first != other.data.first; }
+ ByteArrayIterator& operator++()
+ { ++data.first; data.second += step; return *this; }
+ ByteArrayIterator operator++(int)
+ { ByteArrayIterator result(*this); operator++(); return result; }
+ ByteArrayIterator& operator--()
+ { --data.first; data.second -= step; return *this; }
+ ByteArrayIterator operator--(int)
+ { ByteArrayIterator result(*this); operator--(); return result; }
+ ByteArrayIterator& operator+=(size_t amt)
+ { data.first += amt; data.second += amt*step; return *this; }
+ ByteArrayIterator& operator-=(size_t amt)
+ { data.first -= amt; data.second -= amt*step; return *this; }
+ MBEntityHandle operator-( const ByteArrayIterator& other ) const
+ { return data.first - other.data.first; }
+ const data_type& operator*() const
+ { return data; }
+ const data_type* operator->() const
+ { return &data; }
+};
+
+#endif
+
Modified: MOAB/trunk/TagServer.cpp
===================================================================
--- MOAB/trunk/TagServer.cpp 2008-01-14 19:48:15 UTC (rev 1520)
+++ MOAB/trunk/TagServer.cpp 2008-01-14 19:50:39 UTC (rev 1521)
@@ -759,19 +759,27 @@
}
MBErrorCode TagServer::get_entities_with_tag_value( const MBEntityType type,
- const MBTag tag_handle,
- const void* value,
- MBRange &entities )
+ const MBTag tag_handle,
+ const void* value,
+ MBRange &entities,
+ int value_size )
{
MBErrorCode result = MB_TAG_NOT_FOUND;
MBTagId id = ID_FROM_TAG_HANDLE(tag_handle);
+
+ const TagInfo* info = get_tag_info( tag_handle );
+ if (!info)
+ return MB_TAG_NOT_FOUND;
+ if (!value_size && info->get_size() != MB_VARIABLE_LENGTH)
+ value_size = info->get_size();
+
switch (PROP_FROM_TAG_HANDLE(tag_handle)) {
case MB_TAG_SPARSE:
- result = mSparseData->get_entities_with_tag_value(id, type, entities, value);
+ result = mSparseData->get_entities_with_tag_value(id, *info, type, entities, value, value_size);
break;
case MB_TAG_DENSE:
- result = sequenceManager->get_entities_with_tag_value(id, type, entities, value);
+ result = sequenceManager->get_entities_with_tag_value(id, *info, type, entities, value, value_size);
break;
case MB_TAG_BIT:
result = mBitServer->get_entities_with_tag_value(id, type,
@@ -790,17 +798,25 @@
const MBEntityType type,
const MBTag tag_handle,
const void* value,
- MBRange &entities )
+ MBRange &entities,
+ int value_size )
{
MBErrorCode result = MB_TAG_NOT_FOUND;
MBTagId id = ID_FROM_TAG_HANDLE(tag_handle);
+
+ const TagInfo* info = get_tag_info( tag_handle );
+ if (!info)
+ return MB_TAG_NOT_FOUND;
+ if (!value_size && info->get_size() != MB_VARIABLE_LENGTH)
+ value_size = info->get_size();
+
switch (PROP_FROM_TAG_HANDLE(tag_handle)) {
case MB_TAG_SPARSE:
- result = mSparseData->get_entities_with_tag_value(range, id, type, entities, value);
+ result = mSparseData->get_entities_with_tag_value(range, id, *info, type, entities, value, value_size);
break;
case MB_TAG_DENSE:
- result = sequenceManager->get_entities_with_tag_value(range, id, type, entities, value);
+ result = sequenceManager->get_entities_with_tag_value(range, id, *info, type, entities, value, value_size);
break;
case MB_TAG_BIT:
result = mBitServer->get_entities_with_tag_value(range, id, type,
Modified: MOAB/trunk/TagServer.hpp
===================================================================
--- MOAB/trunk/TagServer.hpp 2008-01-14 19:48:15 UTC (rev 1520)
+++ MOAB/trunk/TagServer.hpp 2008-01-14 19:50:39 UTC (rev 1521)
@@ -132,14 +132,16 @@
MBErrorCode get_entities_with_tag_value( const MBEntityType type,
const MBTag tag_handle,
const void* value,
- MBRange &entities );
+ MBRange &entities,
+ int value_size = 0 );
//! gets all entity handles that match a type, tag and tag value
MBErrorCode get_entities_with_tag_value( const MBRange &input_range,
const MBEntityType type,
const MBTag tag_handle,
const void* value,
- MBRange &entities );
+ MBRange &entities,
+ int value_size = 0 );
MBErrorCode get_entities_with_tag_values( const MBRange &input_range,
const MBEntityType type,
Modified: MOAB/trunk/VarLenTag.hpp
===================================================================
--- MOAB/trunk/VarLenTag.hpp 2008-01-14 19:48:15 UTC (rev 1520)
+++ MOAB/trunk/VarLenTag.hpp 2008-01-14 19:50:39 UTC (rev 1521)
@@ -196,19 +196,19 @@
mData.mPointer.size = 0;
}
-inline VarLenTag( const VarLenTag& copy )
+inline VarLenTag::VarLenTag( const VarLenTag& copy )
: VarLenTagData( copy )
{
-#ifdef
+#ifdef VAR_LEN_TAG_ELIDE_DATA
if (size() > INLINE_COUNT)
#endif
{
- copy.mData.mPointer.array = reinterpret_cast<unsigned char*>(malloc(size()));
+ mData.mPointer.array = reinterpret_cast<unsigned char*>(malloc(size()));
memcpy( copy.mData.mPointer.array, mData.mPointer.array, size() );
}
}
-inline VarLenTag( unsigned size, void* data )
+inline VarLenTag::VarLenTag( unsigned size, void* data )
{
mData.mPointer.size = 0;
if (size)
More information about the moab-dev
mailing list