<commit_before>
// Copyright (c) 2012 <NAME> <<EMAIL>>
// Distributed under the Modified BSD License, see license.txt.

#include "volume_reader_blocked.h"

#include <memory.h>

#include <scm/core/io/file.h>

namespace {

} // namespace


namespace scm {
namespace gl {

volume_reader_blocked::volume_reader_blocked(const std::string& file_path,
                                                   bool         file_unbuffered)
  : volume_reader(file_path, file_unbuffered)
  , _data_start_offset(0)
{
}

volume_reader_blocked::~volume_reader_blocked()
{
}

bool
volume_reader_blocked::read(const scm::math::vec3ui& o,
                            const scm::math::vec3ui& s,
                                  void*              d)
{
    using namespace scm;
    using namespace scm::gl;
    using namespace scm::math;

    if (!(*this)) {
        return false;
    }

    if (   o == vec3ui(0u)
        && s == _dimensions) {
        // read complete volume
        scm::int64 read_size =    static_cast<scm::int64>(_dimensions.x)
                                * static_cast<scm::int64>(_dimensions.y)
                                * static_cast<scm::int64>(_dimensions.z)
                                * static_cast<scm::int64>(size_of_format(_format));

        if (_file->read(d, _data_start_offset, read_size) != read_size) {
            return false;<commit_msg>fixed blocked_volume reader for offsets outside of volume dimensions<commit_after>
// Copyright (c) 2012 <NAME> <<EMAIL>>
// Distributed under the Modified BSD License, see license.txt.

#include "volume_reader_blocked.h"

#include <memory.h>

#include <scm/core/io/file.h>

namespace {

} // namespace


namespace scm {
namespace gl {

volume_reader_blocked::volume_reader_blocked(const std::string& file_path,
                                                   bool         file_unbuffered)
  : volume_reader(file_path, file_unbuffered)
  , _data_start_offset(0)
{
}

volume_reader_blocked::~volume_reader_blocked()
{
}

bool
volume_reader_blocked::read(const scm::math::vec3ui& o,
                            const scm::math::vec3ui& s,
                                  void*              d)
{
    using namespace scm;
    using namespace scm::gl;
    using namespace scm::math;

    if (!(*this)) {
        return false;
    }

    if (   o.x >= _dimensions.x
        || o.y >= _dimensions.y
        || o.z >= _dimensions.z) {
        return true;
    }

    if (   o == vec3ui(0u)
        && s == _dimensions) {
        // read complete volume
        scm::int64 read_size =    static_cast<scm::int64>(_dimensions.x)
                                * static_cast<scm::int64>(_dimensions.y)
                                * static_cast<scm::int64>(_dimensions.z)
                                * static_cast<scm::int64>(size_of_format(_format));

        if (_file->read(d, _data_start_offset, read_size) != read_size) {
            return false;
{'fraction_non_alphanumeric': 0.11525307797537619, 'fraction_numerical': 0.012995896032831737, 'mean_word_length': 2.0061664953751284, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '979276', 'n_tokens_mistral': 947, 'n_tokens_neox': 903, 'n_words': 172}