Skip to content
Snippets Groups Projects
SelectionBoundingBox.cpp 1.78 KiB
Newer Older
/*
 * Distributed under the OSI-approved Apache License, Version 2.0.  See
 * accompanying file Copyright.txt for details.
 *
 * SelectionBoundingBox.cpp
 *
 *  Created on: May 17, 2017
 *      Author: Norbert Podhorszki pnorbert@ornl.gov
 *              William F Godoy godoywf@ornl.gov
 *
 */

#include "SelectionBoundingBox.h"

/// \cond EXCLUDE_FROM_DOXYGEN
#include <stdexcept>
/// \endcond

#include "adios2/helper/adiosFunctions.h" //Uint64VectorToSizetVector

namespace adios
{

// SelectionBoundingBox::SelectionBoundingBox(const std::vector<uint64_t> start,
//                                           const std::vector<uint64_t> count,
//                                           const bool debugMode)
//: Selection(SelectionType::BoundingBox, debugMode),
//  m_Start(Uint64VectorToSizetVector(start)),
//  m_Count(Uint64VectorToSizetVector(count))
//{
//    if (m_DebugMode == true)
//    {
//        CheckBoundingBox();
//    }
//}

SelectionBoundingBox::SelectionBoundingBox(const Dims start, const Dims count,
                                           const bool debugMode)
: Selection(SelectionType::BoundingBox, debugMode), m_Start(start),
  m_Count(count)
{
}

void SelectionBoundingBox::CheckBoundingBox()
{

    if (m_DebugMode == true)
    {
        auto lf_Throw = [](const std::string &message) {
            throw std::invalid_argument(
                "ERROR: " + message +
                ", in call to SelectionBoundingBox constructor\n");
        };

        if (m_Start.size() != m_Count.size())
        {
            lf_Throw("start and count must have the same size");
        }

        if (m_Start.empty())
        {
            lf_Throw("start is empty");
        }

        if (m_Count.empty())
        {
            lf_Throw("count is empty");
        }
    }
}

} // end namespace adios