Пример #1
0
void DebugOutput::list_range_real( const char* pfx, const Range& range )
{
  if (pfx) {
    lineBuffer.insert( lineBuffer.end(), pfx, pfx+strlen(pfx) );
    lineBuffer.push_back(' ');
  }

  if (range.empty()) {
    print_real("<empty>\n");
    return;
  }

  char numbuf[48]; // unsigned 64 bit integer can't have more than 20 decimal digits
  Range::const_pair_iterator i;
  EntityType type = MBMAXTYPE;
  for (i = range.const_pair_begin(); i != range.const_pair_end(); ++i) {
    if (TYPE_FROM_HANDLE(i->first) != type) {
      type = TYPE_FROM_HANDLE(i->first);
      const char* name = CN::EntityTypeName(type);
      lineBuffer.insert( lineBuffer.end(), name, name+strlen(name) );
    }
    if (i->first == i->second) 
      sprintf(numbuf, " %lu,", (unsigned long)(ID_FROM_HANDLE(i->first)));
    else
      print_range(numbuf, ID_FROM_HANDLE(i->first), ID_FROM_HANDLE(i->second) );
    lineBuffer.insert( lineBuffer.end(), numbuf, numbuf+strlen(numbuf) );
  }

  lineBuffer.push_back('\n');
  process_line_buffer();
}
Пример #2
0
    static ErrorCode ent_not_found( Error* error, std::string name, EntityHandle h )
{
  error->set_last_error( "Invalid entity handle setting tag %s: %s %ld", 
                         name.c_str(),
                         CN::EntityTypeName(TYPE_FROM_HANDLE(h)), 
                         (unsigned long)ID_FROM_HANDLE(h));
    
  return MB_ENTITY_NOT_FOUND;
}
Пример #3
0
    static ErrorCode not_found( Error* error, std::string name, EntityHandle h )
{
  if (h)
    error->set_last_error( "No dense tag %s value for %s %ld", 
                           name.c_str(),
                           CN::EntityTypeName(TYPE_FROM_HANDLE(h)), 
                           (unsigned long)ID_FROM_HANDLE(h));
  else
    error->set_last_error( "No tag value for root set" );
    
  return MB_TAG_NOT_FOUND;
}
Пример #4
0
ErrorCode RangeSetIterator::get_next_by_type(const EntityHandle *&ptr, int count,
                                             std::vector<EntityHandle> &arr, bool &atend)
{
  unsigned int num_ret = 0;
  bool max_type = (entType == MBMAXTYPE);
  size_t idx = 0;
    // initialize to first relevant handle
  while ((int)idx < count &&
         (iterPos > ptr[idx+1] ||
          (!max_type && !iterPos && CREATE_HANDLE(entType, ID_FROM_HANDLE(iterPos)) > ptr[idx+1])))
    idx += 2;
  if ((int)idx == count || TYPE_FROM_HANDLE(ptr[idx]) > entType) {
    atend = true;
    return MB_SUCCESS;
  }
  if (!iterPos && max_type) iterPos = ptr[idx];
  else if (!iterPos && 
           TYPE_FROM_HANDLE(ptr[idx]) <= entType &&
           TYPE_FROM_HANDLE(ptr[idx+1]) >= entType) {
    iterPos = std::max(CREATE_HANDLE(entType,1), ptr[idx]);
  }
  
    // idx points to start of subrange, iterPos in that subrange
  do {
    EntityHandle next = ptr[idx+1];
    if (TYPE_FROM_HANDLE(next) != entType && !max_type) next = LAST_HANDLE(entType);
    unsigned int this_ret = chunkSize-num_ret;
    unsigned int to_end = next - iterPos + 1;
    if (to_end < this_ret) this_ret = to_end;
    std::copy(MeshSet::hdl_iter(iterPos), MeshSet::hdl_iter(iterPos + this_ret),
              std::back_inserter(arr));
    if (this_ret == to_end) {
      idx += 2;
      iterPos = ((int)idx < count ? ptr[idx] : 0);
    }
    else iterPos += this_ret;

    num_ret += this_ret;
  }
  while ((int)idx < count && num_ret < chunkSize && 
         iterPos && (max_type || TYPE_FROM_HANDLE(iterPos) == entType));

  if (!iterPos || (!max_type && TYPE_FROM_HANDLE(iterPos) != entType)) atend = true;

  return MB_SUCCESS;
}
Пример #5
0
static ErrorCode not_root_set(const std::string& name, EntityHandle h)
{
  MB_SET_ERR(MB_VARIABLE_DATA_LENGTH, "Cannot get/set mesh/global tag " << name << " on non-root-set " << CN::EntityTypeName(TYPE_FROM_HANDLE(h)) << " " << (unsigned long)ID_FROM_HANDLE(h));
}