text:
#include "termination_handler.hpp"
#include "log.hpp"
#include "filesystem/filesystem.hpp"

#include <cxxabi.h>
#include <thread>
#include <chrono>
#include <fstream>
#include <sstream>

#ifndef WINDOWS
#   include <signal.h>
#endif

#define BOOST_STACKTRACE_USE_BACKTRACE
#include <boost/stacktrace.hpp>

//#####################################################################################################################
[[noreturn]] void onTerminate() noexcept
{
    if (auto exc = std::current_exception())
    {
        // we have an exception
        LOG() << "uncaught exception in terminate handler: \n";
        int status;
        LOGEX(false) << '\t' << abi::__cxa_demangle(abi::__cxa_current_exception_type()->name(), 0, 0, &status) << "\n";
        std::stringstream sstr;
        LOGEX(false) << "-------------\n";
        sstr << boost::stacktrace::stacktrace();
        sstr << sstr.str() << "\n";
        LOGEX(false) << "-------------\n";
        try
        {
            rethrow_exception(exc); // throw to recognize the type
        }
        catch (std::exception const& exc)
        {
            LOGEX(false) << '\t' << exc.what() << "\n";
        }
        catch (...)
        {
            LOGEX(false) << "WARNING! This is not a derivative of std::exception" << "\n";
            LOGEX(false) << "This is a severe error" << "\n";
            // additional action
        }
        std::_Exit(EXIT_FAILURE);
    }

    std::_Exit(EXIT_FAILURE);
}
//---------------------------------------------------------------------------------------------------------------------
[[noreturn]] void onBadSignal(int signal) noexcept
{
    boost::stacktrace::safe_dump_to("./backtrace.dump");

    LOG() << "handling signal: ";
    switch (signal)
    {
        case SIGABRT:
            LOGEX(false) << "SIGABRT\n";
            break;
        case SIGFPE:
            LOGEX(false) << "SIGFPE\n";
            break;
        case SIGILL:
            LOGEX(false) << "SIGILL\n";
            break;
        case SIGSEGV:
            LOGEX(false) << "SIGSEGV\n";
            break;
    }

    std::stringstream sstr;
    LOGEX(false) << "-------------\n";
    sstr << boost::stacktrace::stacktrace();
    LOGEX(false) << sstr.str();
    LOGEX(false) << "-------------\n";

    std::_Exit(EXIT_FAILURE);
}
//---------------------------------------------------------------------------------------------------------------------
void parseAndLogPreviousDump()
{
    if (sfs::exists("./backtrace.dump"))
    {
        std::ifstream ifs("./backtrace.dump");

        boost::stacktrace::stacktrace st = boost::stacktrace::stacktrace::from_dump(ifs);
        std::stringstream sstr;
        sstr << "Previous run crashed:\n" << st << std::endl;
        LOG() << sstr.str();

        // cleaning up
        ifs.close();
        sfs::remove("./backtrace.dump");
    }
}
//#####################################################################################################################


text:
// Boost.Geometry (aka GGL, Generic Geometry Library)

// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.

// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.

// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_GEOMETRY_ALGORITHMS_CLEAR_HPP
#define BOOST_GEOMETRY_ALGORITHMS_CLEAR_HPP

#include <boost/type_traits/remove_const.hpp>

#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/variant_fwd.hpp>

#include <boost/geometry/algorithms/not_implemented.hpp>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/exterior_ring.hpp>
#include <boost/geometry/core/interior_rings.hpp>
#include <boost/geometry/core/mutable_range.hpp>
#include <boost/geometry/core/tag_cast.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>

namespace boost { namespace geometry
{

#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace clear
{

template <typename Geometry>
struct collection_clear
{
    static inline void apply(Geometry& geometry)
    {
        traits::clear<Geometry>::apply(geometry);
    }
};

template <typename Polygon>
struct polygon_clear
{
    static inline void apply(Polygon& polygon)
    {
        traits::clear
            <
                typename boost::remove_reference
                    <
                        typename traits::interior_mutable_type<Polygon>::type
                    >::type
            >::apply(interior_rings(polygon));
        traits::clear
            <
                typename boost::remove_reference
                    <
                        typename traits::ring_mutable_type<Polygon>::type
                    >::type
            >::apply(exterior_ring(polygon));
    }
};

template <typename Geometry>
struct no_action
{
    static inline void apply(Geometry& )
    {
    }
};

}} // namespace detail::clear
#endif // DOXYGEN_NO_DETAIL

#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{

template
<
    typename Geometry,
    typename Tag = typename tag_cast<typename tag<Geometry>::type, multi_tag>::type
>
struct clear: not_implemented<Tag>
{};

// Point/box/segment do not have clear. So specialize to do nothing.
template <typename Geometry>
struct clear<Geometry, point_tag>
    : detail::clear::no_action<Geometry>
{};

template <typename Geometry>
struct clear<Geometry, box_tag>
    : detail::clear::no_action<Geometry>
{};

template <typename Geometry>
struct clear<Geometry, segment_tag>
    : detail::clear::no_action<Geometry>
{};

template <typename Geometry>
struct clear<Geometry, linestring_tag>
    : detail::clear::collection_clear<Geometry>
{};

template <typename Geometry>
struct clear<Geometry, ring_tag>
    : detail::clear::collection_clear<Geometry>
{};

// Polygon can (indirectly) use std for clear
template <typename Polygon>
struct clear<Polygon, polygon_tag>
    : detail::clear::polygon_clear<Polygon>
{};

template <typename Geometry>
struct clear<Geometry, multi_tag>
    : detail::clear::collection_clear<Geometry>
{};

} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH

namespace resolve_variant {

template <typename Geometry>
struct clear
{
    static inline void apply(Geometry& geometry)
    {
        dispatch::clear<Geometry>::apply(geometry);
    }
};

template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
struct clear<variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
{
    struct visitor: static_visitor<void>
    {
        template <typename Geometry>
        inline void operator()(Geometry& geometry) const
        {
            clear<Geometry>::apply(geometry);
        }
    };

    static inline void apply(variant<BOOST_VARIANT_ENUM_PARAMS(T)>& geometry)
    {
        apply_visitor(visitor(), geometry);
    }
};

} // namespace resolve_variant

/*!
\brief Clears a linestring, ring or polygon (exterior+interiors) or multi*
\details Generic function to clear a geometry. All points will be removed from the collection or collections
    making up the geometry. In most cases this is equivalent to the .clear() method of a std::vector<...>. In
    the case of a polygon, this clear functionality is automatically called for the exterior ring, and for the
    interior ring collection. In the case of a point, boxes and segments, nothing will happen.
\ingroup clear
\tparam Geometry \tparam_geometry
\param geometry \param_geometry which will be cleared
\note points and boxes cannot be cleared, instead they can be set to zero by "assign_zero"

\qbk{[include reference/algorithms/clear.qbk]}
*/
template <typename Geometry>
inline void clear(Geometry& geometry)
{
    concept::check<Geometry>();

    resolve_variant::clear<Geometry>::apply(geometry);
}

}} // namespace boost::geometry

#endif // BOOST_GEOMETRY_ALGORITHMS_CLEAR_HPP

ext: hpp

max_stars_repo_name: Abce/boost

max_issues_repo_name: Abce/boost

max_forks_repo_name: Abce/boost


text:
// -----------------------------------------------------------------------
// RTToolbox - DKFZ radiotherapy quantitative evaluation library
//
// Copyright (c) German Cancer Research Center (DKFZ),
// Software development for Integrated Diagnostics and Therapy (SIDT).
// ALL RIGHTS RESERVED.
// See rttbCopyright.txt or
// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE.  See the above copyright notices for more information.
//
//------------------------------------------------------------------------

#include "rttbRosuMappableDoseAccessor.h"

#include <boost/make_shared.hpp>

#include "rttbNullPointerException.h"
#include "rttbMappingOutsideOfImageException.h"
#include "rttbLinearInterpolation.h"

namespace rttb
{
	namespace interpolation
	{
		RosuMappableDoseAccessor::RosuMappableDoseAccessor(const core::GeometricInfo& geoInfoTargetImage,
            core::DoseAccessorInterface::ConstPointer doseMovingImage,
		        const TransformationInterface::Pointer aTransformation,
		        bool acceptPadding,
		        DoseTypeGy defaultOutsideValue): MappableDoseAccessorInterface(geoInfoTargetImage, doseMovingImage,
			                aTransformation, acceptPadding, defaultOutsideValue)
		{
			//define linear interpolation
      auto interpolationLinear = ::boost::make_shared<LinearInterpolation>();
			_spInterpolation = interpolationLinear;
			_spInterpolation->setAccessorPointer(_spOriginalDoseDataMovingImage);
		}

		GenericValueType RosuMappableDoseAccessor::getValueAt(const VoxelGridID aID) const
		{
			VoxelGridIndex3D aVoxelGridIndex3D;

			if (_geoInfoTargetImage.convert(aID, aVoxelGridIndex3D))
			{
				return getValueAt(aVoxelGridIndex3D);
			}
			else
			{
				if (_acceptPadding)
				{
					return _defaultOutsideValue;
				}
				else
				{
					throw core::MappingOutsideOfImageException("Error in conversion from index to world coordinates");
				}
			}
		}

		GenericValueType RosuMappableDoseAccessor::getValueAt(const VoxelGridIndex3D& aIndex) const
		{
			//Transform requested voxel coordinates of original image into world coordinates with RTTB
			WorldCoordinate3D worldCoordinateTarget;

			if (_geoInfoTargetImage.indexToWorldCoordinate(aIndex, worldCoordinateTarget))
			{
				std::vector<WorldCoordinate3D> octants = getOctants(worldCoordinateTarget);

				if (octants.size() > 2)
				{
					DoseTypeGy interpolatedDoseValue = 0.0;

					//get trilinear interpolation value of every octant point
					for (std::vector<WorldCoordinate3D>::const_iterator octantIterator = octants.begin();
					     octantIterator != octants.end();
					     ++octantIterator)
					{
						//transform coordinates
						WorldCoordinate3D worldCoordinateMoving;
						WorldCoordinate3D worldCoordinateTargetOctant = *octantIterator;
						_spTransformation->transformInverse(worldCoordinateTargetOctant, worldCoordinateMoving);

						try
						{
							interpolatedDoseValue += _spInterpolation->getValue(worldCoordinateMoving);
						}
						//Mapped outside of image? Check if padding is allowed
						catch (core::MappingOutsideOfImageException& /*e*/)
						{
							if (_acceptPadding)
							{
								interpolatedDoseValue += _defaultOutsideValue;
							}
							else
							{
								throw core::MappingOutsideOfImageException("Mapping outside of image");
							}
						}
						catch (core::Exception& e)
						{
							std::cout << e.what() << std::endl;
							return -1;
						}
					}

					return interpolatedDoseValue / (DoseTypeGy)octants.size();
				}
				else
				{
					if (_acceptPadding)
					{
						return _defaultOutsideValue;
					}
					else
					{
						throw core::MappingOutsideOfImageException("Too many samples are mapped outside the image!");
					}
				}
			}
			else
			{
				if (_acceptPadding)
				{
					return _defaultOutsideValue;
				}
				else
				{
					throw core::MappingOutsideOfImageException("Error in conversion from index to world coordinates");
				}
			}
		}

		std::vector<WorldCoordinate3D> RosuMappableDoseAccessor::getOctants(
		    const WorldCoordinate3D& aCoordinate) const
		{
			std::vector<WorldCoordinate3D> octants;
			SpacingVectorType3D spacingTargetImage = _geoInfoTargetImage.getSpacing();

			core::GeometricInfo geometricInfoDoseData = _spOriginalDoseDataMovingImage->getGeometricInfo();

			//as the corner point is the coordinate of the voxel (grid), 0.25 and 0.75 are the center of the subvoxels
			for (double xOct = -0.25; xOct <= 0.25; xOct += 0.5)
			{
				for (double yOct = -0.25; yOct <= 0.25; yOct += 0.5)
				{
					for (double zOct = -0.25; zOct <= 0.25; zOct += 0.5)
					{
						WorldCoordinate3D aWorldCoordinate(aCoordinate.x() + (xOct * spacingTargetImage.x()),
						                                   aCoordinate.y() + (yOct * spacingTargetImage.y()),
						                                   aCoordinate.z() + (zOct * spacingTargetImage.z()));

						if (geometricInfoDoseData.isInside(aWorldCoordinate))
						{
							octants.push_back(aWorldCoordinate);
						}
					}
				}
			}

			return octants;
		}

	}//end namespace interpolation
}//end namespace rttb

ext: cpp

max_stars_repo_name: MIC-DKFZ/RTTB

max_issues_repo_name: MIC-DKFZ/RTTB

max_forks_repo_name: MIC-DKFZ/RTTB


text:
/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-

   this file is part of rcssserver3D
   Fri May 9 2003
   Copyright (C) 2002,2003 Koblenz University
   Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group
   $Id$

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

   Class

   HISTORY:
                04.06.2002 MK
                        - initial version

*/
#ifndef Q_MOC_RUN
#include <boost/tokenizer.hpp>
#endif
#include "node.h"
#include <salt/path.h>
#include <iostream>

/*
std::ostream& zeitgeist::operator<<(std::ostream& output, const Node& node)
{
        output << (int)&node << " '" << node.GetName() << "'" << std::endl;

        //for (Node::TLeafList::const_iterator i=leaf.mChildren.begin(); i!=leaf.mChildren.end(); ++i)
        //{
        //      output << *(*i);
        //}
        return output;
}*/

//=============================================================================
using namespace boost;
using namespace salt;
using namespace std;
using namespace zeitgeist;

Node::Node(const std::string& name) : Leaf(name)
{
}

Node::~Node()
{
}

boost::shared_ptr<Leaf>
Node::GetChild(const std::string& name, bool recursive)
{
    boost::shared_ptr<Leaf> leaf   = Leaf::GetChild(name, recursive);

    if (leaf.get() != NULL) return leaf;

    for (TLeafList::iterator i = mChildren.begin(); i != mChildren.end(); ++i)
    {
        // check if we have found a match and return it
        if ((*i)->GetName().compare(name) == 0)
            return (*i);

        if (recursive)
        {
            boost::shared_ptr<Leaf> ret = (*i)->GetChild(name, recursive);
            if (ret.get() != NULL) return ret;
        }
    }

    return boost::shared_ptr<Leaf>();
}

boost::shared_ptr<Leaf>
Node::GetChildOfClass(const std::string& name, bool recursive)
{
    for (TLeafList::iterator i = mChildren.begin(); i != mChildren.end(); ++i)
    {
        // check if we have found a match and add it
        boost::shared_ptr<Class> theClass = (*i)->GetClass();
        if (theClass.get() != NULL && theClass->GetName().compare(name) == 0)
        {
            return (*i);
        }

        if (recursive)
        {
            boost::shared_ptr<Leaf> ret = (*i)->GetChildOfClass(name, recursive);
            if (ret.get() != NULL) return ret;
        }
    }

    return boost::shared_ptr<Leaf>();
}

boost::shared_ptr<Leaf>
Node::GetChildSupportingClass(const std::string& name, bool recursive)
{
    for (TLeafList::iterator i = mChildren.begin(); i != mChildren.end(); ++i)
    {
        // check if we have found a match and add it
        boost::shared_ptr<Class> theClass = (*i)->GetClass();
        if (theClass.get() != NULL && theClass->SupportsClass(name))
        {
            return (*i);
        }

        if (recursive)
        {
            boost::shared_ptr<Leaf> ret = (*i)->GetChildSupportingClass(name, recursive);
            if (ret.get() != NULL) return ret;
        }
    }

    return boost::shared_ptr<Leaf>();
}

void
Node::GetChildren(const std::string& name, TLeafList& baseList, bool recursive)
{
    Leaf::GetChildren(name, baseList, recursive);

    for (TLeafList::iterator i = mChildren.begin(); i != mChildren.end(); ++i)
    {
        // check if we have found a match and add it
        if ((*i)->GetName().compare(name) == 0)
        {
            baseList.push_back(*i);
        }

        if (recursive)
            (*i)->GetChildren(name, baseList, recursive);
    }
}

void
Node::GetChildrenOfClass(const std::string& name, TLeafList& baseList, bool recursive)
{
    Leaf::GetChildrenOfClass(name, baseList, recursive);

    for (TLeafList::iterator i = mChildren.begin(); i != mChildren.end(); ++i)
    {
        // check if we have found a match and add it
        boost::shared_ptr<Class> theClass = (*i)->GetClass();
        if (theClass.get() != NULL && theClass->GetName().compare(name) == 0)
        {
            baseList.push_back(*i);
        }

        if (recursive)
            (*i)->GetChildrenOfClass(name, baseList, recursive);
    }
}

void
Node::GetChildrenSupportingClass(const std::string& name, TLeafList& baseList, bool recursive)
{
    Leaf::GetChildrenSupportingClass(name, baseList, recursive);

    for (TLeafList::iterator i = mChildren.begin(); i != mChildren.end(); ++i)
    {
        // check if we have found a match and add it
        boost::shared_ptr<Class> theClass = (*i)->GetClass();
        if (theClass.get() != NULL && theClass->SupportsClass(name))
        {
            baseList.push_back(*i);
        }

        if (recursive)
        {
            (*i)->GetChildrenSupportingClass(name, baseList, recursive);
        }
    }
}

int
Node::GetNumberOfChildren() const
{
    return static_cast<int>(mChildren.size());
}

bool
Node::IsLeaf() const
{
    return false;
}

void
Node::RemoveChildReference(const boost::shared_ptr<Leaf>& leaf)
{
    mChildren.remove(leaf);
}

void
Node::UnlinkChildren()
{
    while (! mChildren.empty())
    {
        boost::shared_ptr<Leaf> node = mChildren.front();
        node->UnlinkChildren();
        node->Unlink();
    }
}

bool
Node::AddChildReference(const boost::shared_ptr<Leaf>& leaf)
{
    if (leaf.get() == 0)
    {
        return false;
    }

    if (leaf->GetClass() == 0)
    {
        if (leaf->GetName() != "ClassClass")
        {
            cerr << "(Node::AddChildReference) ERROR: object "
                 << leaf->GetName()
                 << " has no assigned class object." << endl;
        }
        return false;
    }

    mChildren.push_back(leaf);
    leaf->SetParent(static_pointer_cast<Node>(GetSelf().lock()));
    return true;
}

void
Node::Dump() const
{
    Leaf::Dump();
    cout << "Node: numChildren = " << mChildren.size() << endl;

    for (TLeafList::const_iterator i = mChildren.begin(); i!=mChildren.end(); ++i)
    {
        (*i)->Dump();
        cout << endl;
    }

    cout << "End Node" << endl;
}

Leaf::TLeafList::iterator
Node::begin()
{
    return mChildren.begin();
}

Leaf::TLeafList::const_iterator
Node::begin() const
{
    return mChildren.begin();
}

Leaf::TLeafList::iterator
Node::end()
{
    return mChildren.end();
}

Leaf::TLeafList::const_iterator
Node::end() const
{
    return mChildren.end();
}

void
Node::UpdateCached()
{
    Leaf::UpdateCached();

    // update all Leaves found
    for (TLeafList::iterator iter = begin();
         iter != end();
         ++iter
        )
    {
        // node specific update
        (*iter)->UpdateCachedInternal();

        // recurse
        (*iter)->UpdateCached();
    }
}


text:
// Copyright 2004, 2005 The Trustees of Indiana University.

// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

//  Authors: Douglas Gregor
//           Andrew Lumsdaine
#ifndef BOOST_GRAPH_FRUCHTERMAN_REINGOLD_FORCE_DIRECTED_LAYOUT_HPP
#define BOOST_GRAPH_FRUCHTERMAN_REINGOLD_FORCE_DIRECTED_LAYOUT_HPP

#include <cmath>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/named_function_params.hpp>
#include <vector>
#include <list>
#include <algorithm> // for std::min, std::max, std::accumulate
#include <boost/graph/point_traits.hpp>
#include <functional>
#include <numeric>

#include <stdlib.h> // for drand48

namespace boost {

using boost::graph::point_traits;

struct square_distance_attractive_force {
  template<typename Graph, typename T>
  T
  operator()(typename graph_traits<Graph>::edge_descriptor,
             T k,
             T d,
             const Graph&) const
  {
    return d * d / k;
  }
};

struct square_distance_repulsive_force {
  template<typename Graph, typename T>
  T
  operator()(typename graph_traits<Graph>::vertex_descriptor,
             typename graph_traits<Graph>::vertex_descriptor,
             T k,
             T d,
             const Graph&) const
  {
    return k * k / d;
  }
};

template<typename T>
struct linear_cooling {
  typedef T result_type;

  linear_cooling(std::size_t iterations)
    : temp(T(iterations) / T(10)), step(0.1) { }

  linear_cooling(std::size_t iterations, T temp)
    : temp(temp), step(temp / T(iterations)) { }

  T operator()()
  {
    T old_temp = temp;
    temp -= step;
    if (temp < T(0)) temp = T(0);
    return old_temp;
  }

 private:
  T temp;
  T step;
};

struct all_force_pairs
{
  template<typename Graph, typename ApplyForce >
  void operator()(const Graph& g, ApplyForce apply_force)
  {
    typedef typename graph_traits<Graph>::vertex_iterator vertex_iterator;
    vertex_iterator v, end;
    for (tie(v, end) = vertices(g); v != end; ++v) {
      vertex_iterator u = v;
      for (++u; u != end; ++u) {
        apply_force(*u, *v);
        apply_force(*v, *u);
      }
    }
  }
};

namespace detail {
  template<typename Point>
  Point point_difference(const Point& p1, const Point& p2)
  {
    Point result;
    std::size_t dims = point_traits<Point>::dimensions(p1);
    for (std::size_t i = 0; i < dims; ++i)
      result[i] = p1[i] - p2[i];
    return result;
  }

  template<typename Point>
  typename point_traits<Point>::component_type
  point_norm(const Point& p)
  {
#ifndef BOOST_NO_STDC_NAMESPACE
    using std::sqrt;
#endif
    typename point_traits<Point>::component_type result(0);
    std::size_t dims = point_traits<Point>::dimensions(p);
    for (std::size_t i = 0; i < dims; ++i)
      result += p[i] * p[i];
    return sqrt(result);
  }

  template<typename Point>
  void
  maybe_jitter_point(Point& p1, const Point& p2, Point origin, Point extent)
  {
#ifndef BOOST_NO_STDC_NAMESPACE
    using std::sqrt;
    using std::fabs;
    using std::rand;
#endif // BOOST_NO_STDC_NAMESPACE
    typedef typename point_traits<Point>::component_type Dim;
    std::size_t dims = point_traits<Point>::dimensions(p1);
    for (std::size_t i = 0; i < dims; ++i) {
      Dim too_close = extent[i] / Dim(10000);
      if (fabs(p1[i] - p2[i]) < too_close) {
        Dim dist_to_move = sqrt(extent[i]) / Dim(200);
        if (p1[i] - origin[i] < origin[i] + extent[i] - p1[i])
          p1[i] += dist_to_move * Dim(rand() % 100) / Dim(100);
        else
          p1[i] -= dist_to_move * Dim(rand() % 100) / Dim(100);
      }
    }
  }

  template<typename PositionMap, typename DisplacementMap,
           typename RepulsiveForce, typename Graph>
  struct fr_apply_force
  {
    typedef typename graph_traits<Graph>::vertex_descriptor vertex_descriptor;
    typedef typename property_traits<PositionMap>::value_type Point;
    typedef typename point_traits<Point>::component_type Dim;

    fr_apply_force(const PositionMap& position,
                   const DisplacementMap& displacement,
                   Point origin, Point extent,
                   RepulsiveForce repulsive_force, Dim k, const Graph& g)
      : position(position), displacement(displacement), origin(origin),
        extent(extent), repulsive_force(repulsive_force), k(k), g(g)
    {
      dims = point_traits<Point>::dimensions(origin);
    }

    void operator()(vertex_descriptor u, vertex_descriptor v)
    {
#ifndef BOOST_NO_STDC_NAMESPACE
      using std::sqrt;
#endif // BOOST_NO_STDC_NAMESPACE
      if (u != v) {
        // When the vertices land on top of each other, move the
        // first vertex away from the boundaries.
        maybe_jitter_point(position[u], position[v], origin, extent);

        // DPG TBD: Can we use the Topology concept's
        // distance/move_position_toward to handle this?
        Point delta = detail::point_difference(position[v], position[u]);
        Dim dist = detail::point_norm(delta);

        if (dist == Dim(0)) {
          for (std::size_t i = 0; i < dims; ++i)
            displacement[v][i] += 0.01;
        } else {
          Dim fr = repulsive_force(u, v, k, dist, g);

          for (std::size_t i = 0; i < dims; ++i)
            displacement[v][i] += delta[i] / dist * fr;
        }
      }
    }

  private:
    PositionMap position;
    DisplacementMap displacement;
    Point origin;
    Point extent;
    RepulsiveForce repulsive_force;
    Dim k;
    const Graph& g;
    std::size_t dims;
  };

} // end namespace detail

template<typename PositionMap>
struct grid_force_pairs
{
  typedef typename property_traits<PositionMap>::value_type Point;
  typedef typename point_traits<Point>::component_type Dim;

  template<typename Graph>
  explicit
  grid_force_pairs(const Point& origin, const Point& extent,
                   PositionMap position, const Graph& g)
    : origin(origin), extent(extent), position(position)
  {
#ifndef BOOST_NO_STDC_NAMESPACE
    using std::sqrt;
#endif // BOOST_NO_STDC_NAMESPACE
    std::size_t dims = point_traits<Point>::dimensions(origin);
    two_k = Dim(2) * sqrt(std::accumulate(&extent[0], &extent[0] + dims,
                                          Dim(1), std::multiplies<Dim>()));

    num_buckets.resize(dims);
    for (std::size_t i = 0; i < dims; ++i)
      num_buckets[i] = std::size_t(extent[i] / two_k + Dim(1));
  }

  template<typename Graph, typename ApplyForce >
  void operator()(const Graph& g, ApplyForce apply_force)
  {
    typedef typename graph_traits<Graph>::vertex_iterator vertex_iterator;
    typedef typename graph_traits<Graph>::vertex_descriptor vertex_descriptor;
    typedef std::list<vertex_descriptor> bucket_t;
    typedef std::vector<bucket_t> buckets_t;

#ifndef BOOST_NO_STDC_NAMESPACE
    using std::sqrt;
#endif // BOOST_NO_STDC_NAMESPACE
    std::size_t dims = point_traits<Point>::dimensions(origin);

    buckets_t buckets(std::accumulate(&num_buckets[0], &num_buckets[0] + dims,
                                      std::size_t(1),
                                      std::multiplies<std::size_t>()));
    vertex_iterator v, v_end;
    for (tie(v, v_end) = vertices(g); v != v_end; ++v) {
      std::vector<std::size_t> bucket(dims);
      for (std::size_t i = 0; i < dims; ++i) {
        bucket[i] = std::size_t((position[*v][i] + origin[i]) / two_k);
        if (bucket[i] >= num_buckets[i]) bucket[i] = num_buckets[i] - 1;
      }
      buckets[bucket_to_index(bucket)].push_back(*v);
    }

    std::vector<std::size_t> cell(2);
    do {
      bucket_t& bucket = buckets[bucket_to_index(cell)];

      std::vector<std::size_t> start_cell(dims);
      std::vector<std::size_t> end_cell(dims);

      for (std::size_t i = 0; i < dims; ++i) {
        start_cell[i] = cell[i] == 0? 0 : cell[i] - 1;
        end_cell[i] = cell[i] == num_buckets[i] - 1? cell[i] : cell[i] + 1;
      }

      // Repulse vertices in this bucket
      typedef typename bucket_t::iterator bucket_iterator;

      std::vector<std::size_t> adj_cell = start_cell;
      do {
        for (bucket_iterator u = bucket.begin(); u != bucket.end(); ++u) {
          // Repulse vertices in this bucket
          bucket_t& other_bucket = buckets[bucket_to_index(adj_cell)];
          for (bucket_iterator v = other_bucket.begin(); v != other_bucket.end(); ++v) {
            Point delta = detail::point_difference(position[*u],
                                                   position[*v]);
            Dim dist = detail::point_norm(delta);
            if (dist < two_k) apply_force(*u, *v);
          }
        }
      } while (next_bucket_in_subgrid(adj_cell, start_cell, end_cell));
    } while (next_bucket(cell));
  }

private:
  bool next_bucket_in_subgrid(std::vector<std::size_t>& bucket,
                              const std::vector<std::size_t>& start,
                              const std::vector<std::size_t>& end)
  {
    // Find the next bucket
    std::size_t index = bucket.size() - 1;
    do {
      if (bucket[index]++ >= end[index]) {
        bucket[index] = start[index];

        if (index == 0)
          return false;
        --index;
      } else {
        return true;
      }
    } while (true);
  }

  bool next_bucket(std::vector<std::size_t>& bucket)
  {
    // Find the next bucket
    std::size_t index = bucket.size() - 1;
    do {
      if (++bucket[index] >= num_buckets[index]) {
        bucket[index] = 0;

        if (index == 0)
          return false;
        --index;
      } else {
        return true;
      }
    } while (true);
  }

  std::size_t bucket_to_index(const std::vector<std::size_t>& bucket)
  {
    std::size_t multiplier = 1;
    std::size_t result = 0;

    std::size_t dims = num_buckets.size();
    for (std::size_t i = 0; i < dims; ++i) {
      result += bucket[i] * multiplier;
      multiplier *= num_buckets[i];
    }
    return result;
  }

  Point origin;
  Point extent;
  PositionMap position;
  Dim two_k;
  std::vector<std::size_t> num_buckets;
};

template<typename PositionMap, typename Graph>
inline grid_force_pairs<PositionMap>
make_grid_force_pairs
  (typename property_traits<PositionMap>::value_type const& origin,
   typename property_traits<PositionMap>::value_type const& extent,
   const PositionMap& position, const Graph& g)
{ return grid_force_pairs<PositionMap>(origin, extent, position, g); }

template<typename Graph, typename PositionMap,
         typename AttractiveForce, typename RepulsiveForce,
         typename ForcePairs, typename Cooling, typename DisplacementMap>
void
fruchterman_reingold_force_directed_layout
 (const Graph&    g,
  PositionMap     position,
  typename property_traits<PositionMap>::value_type const& origin,
  typename property_traits<PositionMap>::value_type const& extent,
  AttractiveForce attractive_force,
  RepulsiveForce  repulsive_force,
  ForcePairs      force_pairs,
  Cooling         cool,
  DisplacementMap displacement)
{
  typedef typename property_traits<PositionMap>::value_type Point;
  typedef typename point_traits<Point>::component_type Dim;
  typedef typename graph_traits<Graph>::vertex_iterator   vertex_iterator;
  typedef typename graph_traits<Graph>::vertex_descriptor vertex_descriptor;
  typedef typename graph_traits<Graph>::edge_iterator     edge_iterator;

#ifndef BOOST_NO_STDC_NAMESPACE
  using std::sqrt;
#endif // BOOST_NO_STDC_NAMESPACE

  std::size_t num_dimensions = point_traits<Point>::dimensions(origin);
  Dim volume = std::accumulate(&extent[0], &extent[0] + num_dimensions,
                               Dim(1), std::multiplies<Dim>());

  // assume positions are initialized randomly
  Dim k = sqrt(volume / num_vertices(g));

  detail::fr_apply_force<PositionMap, DisplacementMap,
                         RepulsiveForce, Graph>
    apply_force(position, displacement, origin, extent, repulsive_force, k, g);

  do {
    // Calculate repulsive forces
    vertex_iterator v, v_end;
    for (tie(v, v_end) = vertices(g); v != v_end; ++v)
      displacement[*v] = Point();
    force_pairs(g, apply_force);

    // Calculate attractive forces
    edge_iterator e, e_end;
    for (tie(e, e_end) = edges(g); e != e_end; ++e) {
      vertex_descriptor v = source(*e, g);
      vertex_descriptor u = target(*e, g);

      if (u != v) {
        // When the vertices land on top of each other, move the
        // first vertex away from the boundaries.
        ::boost::detail::maybe_jitter_point(position[u], position[v],
                                            origin, extent);

        // DPG TBD: Can we use the Topology concept's
        // distance/move_position_toward to handle this?
        Point delta = detail::point_difference(position[v], position[u]);
        Dim dist = detail::point_norm(delta);
        Dim fa = attractive_force(*e, k, dist, g);

        for (std::size_t dim = 0; dim < num_dimensions; ++dim) {
          displacement[v][dim] -= delta[dim] / dist * fa;
          displacement[u][dim] += delta[dim] / dist * fa;
        }
      }
    }

    if (Dim temp = cool()) {
      // Update positions
      for (tie(v, v_end) = vertices(g); v != v_end; ++v) {
        BOOST_USING_STD_MIN();
        BOOST_USING_STD_MAX();
        Dim disp_size = detail::point_norm(displacement[*v]);

        for (std::size_t dim = 0; dim < num_dimensions; ++dim) {
          position[*v][dim] += displacement[*v][dim] / disp_size
                             * (min)(disp_size, temp);
          position[*v][dim] = (min)(origin[dim] + extent[dim],
                                    (max)(origin[dim], position[*v][dim]));
        }
      }
    } else {
      break;
    }
  } while (true);
}

namespace detail {
  template<typename DisplacementMap>
  struct fr_force_directed_layout
  {
    template<typename Graph, typename PositionMap,
             typename AttractiveForce, typename RepulsiveForce,
             typename ForcePairs, typename Cooling,
             typename Param, typename Tag, typename Rest>
    static void
    run(const Graph&    g,
        PositionMap     position,
        typename property_traits<PositionMap>::value_type const& origin,
        typename property_traits<PositionMap>::value_type const& extent,
        AttractiveForce attractive_force,
        RepulsiveForce  repulsive_force,
        ForcePairs      force_pairs,
        Cooling         cool,
        DisplacementMap displacement,
        const bgl_named_params<Param, Tag, Rest>&)
    {
      fruchterman_reingold_force_directed_layout
        (g, position, origin, extent, attractive_force, repulsive_force,
         force_pairs, cool, displacement);
    }
  };

  template<>
  struct fr_force_directed_layout<error_property_not_found>
  {
    template<typename Graph, typename PositionMap,
             typename AttractiveForce, typename RepulsiveForce,
             typename ForcePairs, typename Cooling,
             typename Param, typename Tag, typename Rest>
    static void
    run(const Graph&    g,
        PositionMap     position,
        typename property_traits<PositionMap>::value_type const& origin,
        typename property_traits<PositionMap>::value_type const& extent,
        AttractiveForce attractive_force,
        RepulsiveForce  repulsive_force,
        ForcePairs      force_pairs,
        Cooling         cool,
        error_property_not_found,
        const bgl_named_params<Param, Tag, Rest>& params)
    {
      typedef typename property_traits<PositionMap>::value_type Point;
      std::vector<Point> displacements(num_vertices(g));
      fruchterman_reingold_force_directed_layout
        (g, position, origin, extent, attractive_force, repulsive_force,
         force_pairs, cool,
         make_iterator_property_map
         (displacements.begin(),
          choose_const_pmap(get_param(params, vertex_index), g,
                            vertex_index),
          Point()));
    }
  };

} // end namespace detail

template<typename Graph, typename PositionMap, typename Param,
         typename Tag, typename Rest>
void
fruchterman_reingold_force_directed_layout
  (const Graph&    g,
   PositionMap     position,
   typename property_traits<PositionMap>::value_type const& origin,
   typename property_traits<PositionMap>::value_type const& extent,
   const bgl_named_params<Param, Tag, Rest>& params)
{
  typedef typename property_value<bgl_named_params<Param,Tag,Rest>,
                                  vertex_displacement_t>::type D;

  detail::fr_force_directed_layout<D>::run
    (g, position, origin, extent,
     choose_param(get_param(params, attractive_force_t()),
                  square_distance_attractive_force()),
     choose_param(get_param(params, repulsive_force_t()),
                  square_distance_repulsive_force()),
     choose_param(get_param(params, force_pairs_t()),
                  make_grid_force_pairs(origin, extent, position, g)),
     choose_param(get_param(params, cooling_t()),
                  linear_cooling<double>(100)),
     get_param(params, vertex_displacement_t()),
     params);
}

template<typename Graph, typename PositionMap>
void
fruchterman_reingold_force_directed_layout
  (const Graph&    g,
   PositionMap     position,
   typename property_traits<PositionMap>::value_type const& origin,
   typename property_traits<PositionMap>::value_type const& extent)
{
  fruchterman_reingold_force_directed_layout
    (g, position, origin, extent,
     attractive_force(square_distance_attractive_force()));
}

} // end namespace boost

#ifdef BOOST_GRAPH_IS_PARALLEL
#  include <boost/graph/distributed/fruchterman_reingold.hpp>
#endif // BOOST_GRAPH_IS_PARALLEL

#endif // BOOST_GRAPH_FRUCHTERMAN_REINGOLD_FORCE_DIRECTED_LAYOUT_HPP

max_stars_repo_name: erwinvaneijk/bgl-python

max_issues_repo_name: erwinvaneijk/bgl-python

max_forks_repo_name: erwinvaneijk/bgl-python


text:
//==================================================================================================
/*
  Copyright 2017 NumScale SAS

  Distributed under the Boost Software License, Version 1.0.
  (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
//==================================================================================================
#include <boost/simd/memory/is_aligned.hpp>
#include <boost/simd/memory/deallocate.hpp>
#include <boost/simd/memory/allocate.hpp>
#include <simd_test.hpp>

using namespace boost::simd;

STF_CASE_TPL( "Check is_aligned on default architecture", STF_NUMERIC_TYPES )
{
  T* ptr = allocate<T>( 7 );

  STF_EXPECT    ( is_aligned(ptr)   );
  STF_EXPECT_NOT( is_aligned(ptr+1) );

  deallocate(ptr);
}

STF_CASE_TPL( "Check is_aligned on default architecture", STF_NUMERIC_TYPES )
{
  T* ptr16 = allocate<T>( 7, sse1 );
  T* ptr32 = allocate<T>( 7, avx );

  STF_EXPECT( is_aligned(ptr16, sse1 ));
  STF_EXPECT( is_aligned(ptr16, sse2 ));
  STF_EXPECT( is_aligned(ptr16, sse3 ));
  STF_EXPECT( is_aligned(ptr16, ssse3));
  STF_EXPECT( is_aligned(ptr32, sse1 ));
  STF_EXPECT( is_aligned(ptr32, sse2 ));
  STF_EXPECT( is_aligned(ptr32, sse3 ));
  STF_EXPECT( is_aligned(ptr32, ssse3));
  STF_EXPECT( is_aligned(ptr32, avx  ));
  STF_EXPECT( is_aligned(ptr32, avx2 ));

  deallocate(ptr16);
  deallocate(ptr32);
}


text:
/*
ID: septicmk
LANG: C++
TASK:
*/

#include "MLalgorithm.h"
#include <vector>
#include <boost/serialization/vector.hpp>

max_stars_repo_name: NCIC-PARALLEL/Graphine-LIB

max_issues_repo_name: PAA-NCIC/HPML

max_forks_repo_name: PAA-NCIC/HPML


text:
/*******************************************************************************
Copyright(c) 2015-2020 Parker Hannifin Corp. All rights reserved.

MIT Licensed. See the included LICENSE.txt for a copy of the full MIT License.
*******************************************************************************/
#include "mscl/MicroStrain/MIP/Packets/MipFieldParser.h"
#include "mscl/MicroStrain/MIP/Packets/MipDataPacket.h"
#include "mscl/MicroStrain/MIP/MipDataPoint.h"
#include "mscl/MicroStrain/MIP/MipTypes.h"
#include "mscl/MicroStrain/Inertial/Packets/InertialFieldParser_EstFilter.h"
#include "mscl/MicroStrain/Inertial/ExposedInertialTypes.h"

#include <boost/test/unit_test.hpp>

using namespace mscl;

BOOST_AUTO_TEST_SUITE(InertialFieldParser_EstFilter_Test)

BOOST_AUTO_TEST_CASE(InertialFieldParser_FilterStatus_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_uint16(0x03);    //filter state
    bytes.append_uint16(0x02);    //dynamics mode
    bytes.append_uint16(0x03);    //status flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_FILTER_STATUS, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    //Filter State
    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_FILTER_STATUS);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_FILTER_STATE);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_uint16);
    BOOST_CHECK_EQUAL(data.at(0).valid(), true);
    BOOST_CHECK_EQUAL(data.at(0).as_uint16(), InertialTypes::FILTERSTATE_RUNNING_SLN_ERROR);
    BOOST_CHECK_EQUAL(data.at(0).channelName(), "estFilterState");

    //Dynamics Mode
    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_FILTER_STATUS);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_DYNAMICS_MODE);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_uint16);
    BOOST_CHECK_EQUAL(data.at(1).valid(), true);
    BOOST_CHECK_EQUAL(data.at(1).as_uint16(), InertialTypes::AUTOMOTIVE_VEHICLE);
    BOOST_CHECK_EQUAL(data.at(1).channelName(), "estFilterDynamicsMode");

    //flags
    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_FILTER_STATUS);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_FLAGS);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_uint16);
    BOOST_CHECK_EQUAL(data.at(2).valid(), true);
    BOOST_CHECK_EQUAL(data.at(2).as_uint16(), 0x03);
    BOOST_CHECK_EQUAL(data.at(2).channelName(), "estFilterStatusFlags");
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_GPSTimestamp_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_double(23.45);    //time of week
    bytes.append_uint16(10);    //week number
    bytes.append_uint16(1);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_GPS_TIMESTAMP, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 2);

    //Time of Week
    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_GPS_TIMESTAMP);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_TIME_OF_WEEK);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_double);
    BOOST_CHECK_EQUAL(data.at(0).valid(), true);
    BOOST_CHECK_EQUAL(data.at(0).as_double(), 23.45);
    BOOST_CHECK_EQUAL(data.at(0).channelName(), "estFilterGpsTimeTow");

    //Week Number
    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_GPS_TIMESTAMP);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_WEEK_NUMBER);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_uint16);
    BOOST_CHECK_EQUAL(data.at(1).valid(), true);
    BOOST_CHECK_EQUAL(data.at(1).as_uint16(), 10);
    BOOST_CHECK_EQUAL(data.at(1).channelName(), "estFilterGpsTimeWeekNum");
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedLLHPosition_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_double(1.2);        //latitude
    bytes.append_double(3.4);        //longitude
    bytes.append_double(5.67);        //height above ellipsoid
    bytes.append_uint16(0);            //valid flags (0000 0000)

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_LLH_POS, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    //Latitude
    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_LLH_POS);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_LATITUDE);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_double);
    BOOST_CHECK_EQUAL(data.at(0).valid(), false);
    BOOST_CHECK_CLOSE(data.at(0).as_double(), 1.2, 0.0001);
    BOOST_CHECK_EQUAL(data.at(0).channelName(), "estLatitude");

    //Longitude
    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_LLH_POS);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_LONGITUDE);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_double);
    BOOST_CHECK_EQUAL(data.at(1).valid(), false);
    BOOST_CHECK_CLOSE(data.at(1).as_double(), 3.4, 0.0001);
    BOOST_CHECK_EQUAL(data.at(1).channelName(), "estLongitude");

    //Height Above Ellipsoid
    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_LLH_POS);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_HEIGHT_ABOVE_ELLIPSOID);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_double);
    BOOST_CHECK_EQUAL(data.at(2).valid(), false);
    BOOST_CHECK_CLOSE(data.at(2).as_double(), 5.67, 0.0001);
    BOOST_CHECK_EQUAL(data.at(2).channelName(), "estHeightAboveElipsoid");
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedNEDVelocity_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.1f);    //north
    bytes.append_float(2.2f);    //east
    bytes.append_float(3.3f);    //down
    bytes.append_uint16(1);        //valid flags (0000 0001)

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_NED_VELOCITY, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    //north
    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_NED_VELOCITY);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_NORTH);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), true);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.1, 0.0001);
    BOOST_CHECK_EQUAL(data.at(0).channelName(), "estNorthVelocity");

    //east
    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_NED_VELOCITY);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_EAST);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), true);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 2.2, 0.0001);
    BOOST_CHECK_EQUAL(data.at(1).channelName(), "estEastVelocity");

    //down
    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_NED_VELOCITY);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_DOWN);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), true);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 3.3, 0.0001);
    BOOST_CHECK_EQUAL(data.at(2).channelName(), "estDownVelocity");
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedQuaternion_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(2.345f);    //q0
    bytes.append_float(0.0f);    //q1
    bytes.append_float(0.0f);    //q2
    bytes.append_float(0.0f);    //q3
    bytes.append_uint16(1);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ORIENT_QUATERNION, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 1);
    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ORIENT_QUATERNION);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_QUATERNION);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_Vector);
    BOOST_CHECK_EQUAL(data.at(0).valid(), true);
    BOOST_CHECK_CLOSE(data.at(0).as_Vector().as_floatAt(0), 2.345, 0.0001);
    BOOST_CHECK_EQUAL(data.at(0).as_Vector().as_floatAt(1), 0);
    BOOST_CHECK_EQUAL(data.at(0).as_Vector().as_floatAt(2), 0);
    BOOST_CHECK_EQUAL(data.at(0).as_Vector().as_floatAt(3), 0);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedOrientMatrix_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(0.0f);
    bytes.append_float(1.234f);
    bytes.append_float(2.345f);
    bytes.append_float(3.456f);
    bytes.append_float(0.0f);
    bytes.append_float(9123.2f);
    bytes.append_float(0.0f);
    bytes.append_float(0.0f);
    bytes.append_float(0.0f);
    bytes.append_uint16(0);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ORIENT_MATRIX, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 1);
    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ORIENT_MATRIX);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_MATRIX);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_Matrix);
    BOOST_CHECK_EQUAL(data.at(0).valid(), false);
    BOOST_CHECK_CLOSE(data.at(0).as_Matrix().as_floatAt(0, 0), 0.0, 0.0001);
    BOOST_CHECK_CLOSE(data.at(0).as_Matrix().as_floatAt(0, 1), 1.234, 0.0001);
    BOOST_CHECK_CLOSE(data.at(0).as_Matrix().as_floatAt(0, 2), 2.345, 0.0001);
    BOOST_CHECK_CLOSE(data.at(0).as_Matrix().as_floatAt(1, 0), 3.456, 0.0001);
    BOOST_CHECK_CLOSE(data.at(0).as_Matrix().as_floatAt(1, 1), 0.0, 0.0001);
    BOOST_CHECK_CLOSE(data.at(0).as_Matrix().as_floatAt(1, 2), 9123.2, 0.0001);
    BOOST_CHECK_CLOSE(data.at(0).as_Matrix().as_floatAt(2, 0), 0.0, 0.0001);
    BOOST_CHECK_CLOSE(data.at(0).as_Matrix().as_floatAt(2, 1), 0.0, 0.0001);
    BOOST_CHECK_CLOSE(data.at(0).as_Matrix().as_floatAt(2, 2), 0.0, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedEulerAngles_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(2.345f);    //roll
    bytes.append_float(0.0f);    //pitch
    bytes.append_float(0.0f);    //yaw
    bytes.append_uint16(1);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ORIENT_EULER, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ORIENT_EULER);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_ROLL);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), true);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 2.345, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ORIENT_EULER);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_PITCH);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), true);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 0.0, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ORIENT_EULER);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_YAW);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), true);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 0.0, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedGyroBias_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(2.345f);    //x
    bytes.append_float(0.0f);    //y
    bytes.append_float(0.0f);    //z
    bytes.append_uint16(1);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_GYRO_BIAS, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_GYRO_BIAS);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_X);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), true);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 2.345, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_GYRO_BIAS);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_Y);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), true);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 0.0, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_GYRO_BIAS);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_Z);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), true);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 0.0, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedAccelBias_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(2.345f);    //x
    bytes.append_float(0.0f);    //y
    bytes.append_float(0.0f);    //z
    bytes.append_uint16(1);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ACCEL_BIAS, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ACCEL_BIAS);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_X);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), true);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 2.345, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ACCEL_BIAS);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_Y);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), true);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 0.0, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ACCEL_BIAS);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_Z);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), true);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 0.0, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedLLHUncertainty_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.234f);    //north
    bytes.append_float(4.567f);    //east
    bytes.append_float(9.988f);    //down
    bytes.append_uint16(0);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_LLH_UNCERT, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_LLH_UNCERT);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_NORTH);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), false);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.234, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_LLH_UNCERT);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_EAST);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), false);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 4.567, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_LLH_UNCERT);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_DOWN);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), false);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 9.988, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedNEDUncertainty_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.234f);    //north
    bytes.append_float(4.567f);    //east
    bytes.append_float(9.988f);    //down
    bytes.append_uint16(1);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_NED_UNCERT, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_NED_UNCERT);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_NORTH);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), true);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.234, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_NED_UNCERT);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_EAST);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), true);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 4.567, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_NED_UNCERT);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_DOWN);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), true);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 9.988, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedAttEulerUncertainty_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.234f);    //roll
    bytes.append_float(4.567f);    //pitch
    bytes.append_float(9.988f);    //yaw
    bytes.append_uint16(1);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ATT_UNCERT_EULER, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ATT_UNCERT_EULER);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_ROLL);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), true);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.234, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ATT_UNCERT_EULER);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_PITCH);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), true);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 4.567, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ATT_UNCERT_EULER);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_YAW);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), true);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 9.988, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedGyroBiasUncertainty_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.234f);    //x
    bytes.append_float(4.567f);    //y
    bytes.append_float(9.988f);    //z
    bytes.append_uint16(0);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_GYRO_BIAS_UNCERT, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_GYRO_BIAS_UNCERT);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_X);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), false);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.234, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_GYRO_BIAS_UNCERT);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_Y);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), false);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 4.567, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_GYRO_BIAS_UNCERT);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_Z);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), false);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 9.988, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedAccelBiasUncertainty_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.234f);    //x
    bytes.append_float(4.567f);    //y
    bytes.append_float(9.988f);    //z
    bytes.append_uint16(0);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ACCEL_BIAS_UNCERT, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ACCEL_BIAS_UNCERT);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_X);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), false);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.234, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ACCEL_BIAS_UNCERT);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_Y);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), false);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 4.567, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ACCEL_BIAS_UNCERT);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_Z);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), false);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 9.988, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedLinearAccel_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.234f);    //x
    bytes.append_float(4.567f);    //y
    bytes.append_float(9.988f);    //z
    bytes.append_uint16(0);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_LINEAR_ACCEL, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_LINEAR_ACCEL);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_X);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), false);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.234, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_LINEAR_ACCEL);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_Y);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), false);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 4.567, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_LINEAR_ACCEL);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_Z);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), false);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 9.988, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedAngularRate_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.234f);    //x
    bytes.append_float(4.567f);    //y
    bytes.append_float(9.988f);    //z
    bytes.append_uint16(0);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ANGULAR_RATE, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ANGULAR_RATE);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_X);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), false);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.234, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ANGULAR_RATE);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_Y);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), false);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 4.567, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ANGULAR_RATE);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_Z);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), false);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 9.988, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_WGS84LocalGravMagnitude_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(456.123f);    //gravity magnitude
    bytes.append_uint16(1);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_WGS84_LOC_GRAV_MAGNITUDE, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 1);
    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_WGS84_LOC_GRAV_MAGNITUDE);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_MAGNITUDE);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), true);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 456.123, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedAttQuaternUncertainty_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.234f);    //q0
    bytes.append_float(4.567f);    //q1
    bytes.append_float(9.988f);    //q2
    bytes.append_float(0.001f);    //q3
    bytes.append_uint16(1);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ATT_UNCERT_QUAT, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 1);
    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_ATT_UNCERT_QUAT);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_QUATERNION);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_Vector);
    BOOST_CHECK_EQUAL(data.at(0).valid(), true);
    BOOST_CHECK_CLOSE(data.at(0).as_Vector().as_floatAt(0), 1.234, 0.0001);
    BOOST_CHECK_CLOSE(data.at(0).as_Vector().as_floatAt(1), 4.567, 0.0001);
    BOOST_CHECK_CLOSE(data.at(0).as_Vector().as_floatAt(2), 9.988, 0.0001);
    BOOST_CHECK_CLOSE(data.at(0).as_Vector().as_floatAt(3), 0.001, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedGravityVector_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.234f);    //x
    bytes.append_float(4.567f);    //y
    bytes.append_float(9.988f);    //z
    bytes.append_uint16(0);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_GRAVITY_VECTOR, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_GRAVITY_VECTOR);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_X);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), false);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.234, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_GRAVITY_VECTOR);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_Y);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), false);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 4.567, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_GRAVITY_VECTOR);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_Z);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), false);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 9.988, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_HeadingUpdateSource_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.234f);    //heading
    bytes.append_float(4.567f);    //uncertaininty
    bytes.append_uint16(10);    //source
    bytes.append_uint16(0);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_HEADING_UPDATE_SOURCE, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_HEADING_UPDATE_SOURCE);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_HEADING);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), false);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.234, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_HEADING_UPDATE_SOURCE);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_HEADING_UNCERTAINTY);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), false);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 4.567, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_HEADING_UPDATE_SOURCE);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_SOURCE);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_uint16);
    BOOST_CHECK_EQUAL(data.at(2).valid(), false);
    BOOST_CHECK_EQUAL(data.at(2).as_uint16(), 10);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_MagneticModelSln_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.234f);    //intensity, north
    bytes.append_float(2.345f);    //intensity, east
    bytes.append_float(3.456f);    //intensity, down
    bytes.append_float(4.567f);    //inclination
    bytes.append_float(9.456f);    //declination
    bytes.append_uint16(1);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_MAGNETIC_MODEL_SLN, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    BOOST_CHECK_EQUAL(data.size(), 5);

    //intensity vector
    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_MAGNETIC_MODEL_SLN);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_NORTH);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), true);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.234, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_MAGNETIC_MODEL_SLN);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_EAST);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), true);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 2.345, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_MAGNETIC_MODEL_SLN);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_DOWN);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), true);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 3.456, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());

    //inclination
    BOOST_CHECK_EQUAL(data.at(3).field(), MipTypes::CH_FIELD_ESTFILTER_MAGNETIC_MODEL_SLN);
    BOOST_CHECK_EQUAL(data.at(3).qualifier(), MipTypes::CH_INCLINATION);
    BOOST_CHECK_EQUAL(data.at(3).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(3).valid(), true);
    BOOST_CHECK_CLOSE(data.at(3).as_float(), 4.567, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(3).channelName());

    //declination
    BOOST_CHECK_EQUAL(data.at(4).field(), MipTypes::CH_FIELD_ESTFILTER_MAGNETIC_MODEL_SLN);
    BOOST_CHECK_EQUAL(data.at(4).qualifier(), MipTypes::CH_DECLINATION);
    BOOST_CHECK_EQUAL(data.at(4).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(4).valid(), true);
    BOOST_CHECK_CLOSE(data.at(4).as_float(), 9.456, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(4).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedGyroScaleFactor_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.978f);    //x
    bytes.append_float(4.789f);    //y
    bytes.append_float(16.001f);//z
    bytes.append_uint16(0);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_GYRO_SCALE_FACTOR, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_GYRO_SCALE_FACTOR);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_X);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), false);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.978, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_GYRO_SCALE_FACTOR);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_Y);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), false);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 4.789, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_ESTIMATED_GYRO_SCALE_FACTOR);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_Z);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), false);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 16.001, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedAccelScaleFactor_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.978f);    //x
    bytes.append_float(4.789f);    //y
    bytes.append_float(16.001f);//z
    bytes.append_uint16(1);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ACCEL_SCALE_FACTOR, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ACCEL_SCALE_FACTOR);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_X);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), true);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.978, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_ACCEL_SCALE_FACTOR);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_Y);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), true);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 4.789, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_ACCEL_SCALE_FACTOR);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_Z);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), true);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 16.001, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedGyroScaleFactorUncert_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.978f);    //x
    bytes.append_float(4.789f);    //y
    bytes.append_float(16.001f);//z
    bytes.append_uint16(0);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_GYRO_SCALE_FACTOR_UNCERT, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_GYRO_SCALE_FACTOR_UNCERT);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_X);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), false);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.978, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_GYRO_SCALE_FACTOR_UNCERT);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_Y);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), false);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 4.789, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_GYRO_SCALE_FACTOR_UNCERT);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_Z);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), false);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 16.001, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_EstimatedAccelScaleFactorUncert_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.978f);    //x
    bytes.append_float(4.789f);    //y
    bytes.append_float(16.001f);//z
    bytes.append_uint16(0);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_ACCEL_SCALE_FACTOR_UNCERT, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_ACCEL_SCALE_FACTOR_UNCERT);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_X);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), false);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.978, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_ACCEL_SCALE_FACTOR_UNCERT);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_Y);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), false);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 4.789, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_ACCEL_SCALE_FACTOR_UNCERT);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_Z);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), false);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 16.001, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_CompensatedAccel_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.978f);    //x
    bytes.append_float(4.789f);    //y
    bytes.append_float(16.001f);//z
    bytes.append_uint16(0);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_COMPENSATED_ACCEL, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_COMPENSATED_ACCEL);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_X);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), false);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.978, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_COMPENSATED_ACCEL);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_Y);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), false);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 4.789, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_COMPENSATED_ACCEL);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_Z);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), false);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 16.001, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_StdAtmModel_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.978f);    //geometric altitude
    bytes.append_float(4.789f);    //geopotential altitude
    bytes.append_float(16.001f);//temperature
    bytes.append_float(16.001f);//pressure
    bytes.append_float(16.001f);//density
    bytes.append_uint16(0);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_STD_ATMOSPHERE_MODEL, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 5);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_STD_ATMOSPHERE_MODEL);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_GEOMETRIC_ALTITUDE);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), false);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.978, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_STD_ATMOSPHERE_MODEL);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_GEOPOTENTIAL_ALTITUDE);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), false);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 4.789, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_STD_ATMOSPHERE_MODEL);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_TEMPERATURE);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), false);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 16.001, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());

    BOOST_CHECK_EQUAL(data.at(3).field(), MipTypes::CH_FIELD_ESTFILTER_STD_ATMOSPHERE_MODEL);
    BOOST_CHECK_EQUAL(data.at(3).qualifier(), MipTypes::CH_PRESSURE);
    BOOST_CHECK_EQUAL(data.at(3).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(3).valid(), false);
    BOOST_CHECK_CLOSE(data.at(3).as_float(), 16.001, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(3).channelName());

    BOOST_CHECK_EQUAL(data.at(4).field(), MipTypes::CH_FIELD_ESTFILTER_STD_ATMOSPHERE_MODEL);
    BOOST_CHECK_EQUAL(data.at(4).qualifier(), MipTypes::CH_DENSITY);
    BOOST_CHECK_EQUAL(data.at(4).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(4).valid(), false);
    BOOST_CHECK_CLOSE(data.at(4).as_float(), 16.001, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(4).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_PressureAltitude_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(0.4672f);    //geometric altitude
    bytes.append_uint16(0);            //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_PRESSURE_ALTITUDE, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 1);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_PRESSURE_ALTITUDE);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_ALTITUDE);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), false);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 0.4672, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_GpsAntennaOffsetCorrection_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.978f);    //x
    bytes.append_float(4.789f);    //y
    bytes.append_float(16.001f);//z
    bytes.append_uint16(0);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_GNSS_ANTENNA_CORRECTION, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_GNSS_ANTENNA_CORRECTION);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_X);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), false);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.978, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_GNSS_ANTENNA_CORRECTION);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_Y);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), false);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 4.789, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_GNSS_ANTENNA_CORRECTION);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_Z);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), false);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 16.001, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_CASE(InertialFieldParser_GpsAntennaOffsetCorrectionUncert_parse)
{
    ByteStream bytes;

    //add bytes to the ByteStream
    bytes.append_float(1.978f);    //x
    bytes.append_float(4.789f);    //y
    bytes.append_float(16.001f);//z
    bytes.append_uint16(0);        //flags

    //Create the Data Field
    MipDataField field(MipTypes::CH_FIELD_ESTFILTER_GNSS_ANTENNA_CORRECTION_UNCERT, bytes.data());

    MipDataPoints data;

    MipFieldParser::parseField(field, data);

    //verify the field was parsed correctly
    BOOST_CHECK_EQUAL(data.size(), 3);

    BOOST_CHECK_EQUAL(data.at(0).field(), MipTypes::CH_FIELD_ESTFILTER_GNSS_ANTENNA_CORRECTION_UNCERT);
    BOOST_CHECK_EQUAL(data.at(0).qualifier(), MipTypes::CH_X);
    BOOST_CHECK_EQUAL(data.at(0).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(0).valid(), false);
    BOOST_CHECK_CLOSE(data.at(0).as_float(), 1.978, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(0).channelName());

    BOOST_CHECK_EQUAL(data.at(1).field(), MipTypes::CH_FIELD_ESTFILTER_GNSS_ANTENNA_CORRECTION_UNCERT);
    BOOST_CHECK_EQUAL(data.at(1).qualifier(), MipTypes::CH_Y);
    BOOST_CHECK_EQUAL(data.at(1).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(1).valid(), false);
    BOOST_CHECK_CLOSE(data.at(1).as_float(), 4.789, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(1).channelName());

    BOOST_CHECK_EQUAL(data.at(2).field(), MipTypes::CH_FIELD_ESTFILTER_GNSS_ANTENNA_CORRECTION_UNCERT);
    BOOST_CHECK_EQUAL(data.at(2).qualifier(), MipTypes::CH_Z);
    BOOST_CHECK_EQUAL(data.at(2).storedAs(), valueType_float);
    BOOST_CHECK_EQUAL(data.at(2).valid(), false);
    BOOST_CHECK_CLOSE(data.at(2).as_float(), 16.001, 0.0001);
    BOOST_CHECK_NO_THROW(data.at(2).channelName());
}

BOOST_AUTO_TEST_SUITE_END()

max_stars_repo_name: contagon/MSCL

max_stars_repo_licenses: BSL-1.0 OpenSSL MIT

max_issues_repo_name: contagon/MSCL

max_issues_repo_licenses: BSL-1.0 OpenSSL MIT

max_forks_repo_name: contagon/MSCL

max_forks_repo_licenses: BSL-1.0 OpenSSL MIT


text:
#include <boost/test/unit_test.hpp>

#include "fstest.h"
#include "fscore.h"
#include "fsmem.h"
#include "fsutil.h"

using namespace fs;

using DelegateArena = MemoryArena<Allocator<HeapAllocator, AllocationHeaderU32>,
                                MultiThread<MutexPrimitive>,
                                SimpleBoundsChecking,
                                FullMemoryTracking,
                                MemoryTagging>;

using TestEvent = Event<DelegateArena, void(void)>;

// These are already declared in delegate test. Should namespace them.
void func_VoidVoid();
// {
//     FS_ASSERT(!"Test should verify that invoking delegate triggers this assert");
// }
//
void func_VoidInt(u32 i);
// {
//     ++i;
//     FS_ASSERT(!"Test should verify that invoking delegate triggers this assert");
// }
//
void func_VoidIntInt(u32 a, u32 b);
// {
//     auto c = a+b;
//     (void)c;
//     FS_ASSERT(!"Test should verify that invoking delegate triggers this assert");
// }
//
u32 func_IntInt(u32 i);
// {
//     FS_ASSERT(!"Test should verify that invoking delegate triggers this assert");
//     return i*i;
// }

class DelegateClass
{
    public:
        void func_VoidVoid()
        {
            FS_ASSERT(!"Test should verify that invoking delegate triggers this assert");
        }

        void func_VoidInt(u32 i)
        {
            ++i;
            FS_ASSERT(!"Test should verify that invoking delegate triggers this assert");
        }

        void func_VoidIntInt(u32 a, u32 b)
        {
            auto c = a+b;
            (void)c;
            FS_ASSERT(!"Test should verify that invoking delegate triggers this assert");
        }

        u32 func_IntInt(u32 i)
        {
            FS_ASSERT(!"Test should verify that invoking delegate triggers this assert");
            return i*i;
        }

        void func_VoidVoidConst() const
        {
            FS_ASSERT(!"Test should verify that invoking delegate triggers this assert");
        }

        void func_VoidIntConst(u32 i) const
        {
            ++i;
            FS_ASSERT(!"Test should verify that invoking delegate triggers this assert");
        }

        void func_VoidIntIntConst(u32 a, u32 b) const
        {
            auto c = a+b;
            (void)c;
            FS_ASSERT(!"Test should verify that invoking delegate triggers this assert");
        }

        u32 func_IntIntConst(u32 i) const
        {
            FS_ASSERT(!"Test should verify that invoking delegate triggers this assert");
            return i*i;
        }
};

struct EventFixture
{
    EventFixture() :
        area(FS_SIZE_OF_MB * 4),
        arena(area, "DelegateArena"),
        event(&arena)
    {
    }

    ~EventFixture()
    {
    }

    DelegateClass instance;

    // Order below matters for allocation deallocation order
    HeapArea area;
    DelegateArena arena;
    TestEvent event;
};

BOOST_AUTO_TEST_SUITE(core)
BOOST_FIXTURE_TEST_SUITE(event, EventFixture)

BOOST_AUTO_TEST_CASE(add_to_channel_check_and_remove)
{
    auto channel = event.makeChannel(10);
    auto lambda = [](){};

    BOOST_CHECK(!channel->has<&func_VoidVoid>());
    BOOST_CHECK((!channel->has<DelegateClass, &DelegateClass::func_VoidVoid>(&instance)));
    BOOST_CHECK((!channel->has<DelegateClass, &DelegateClass::func_VoidVoidConst>(&instance)));
    BOOST_CHECK(!channel->has(lambda));

    channel->add<&func_VoidVoid>();
    BOOST_CHECK(channel->size() == 1);
    channel->add<DelegateClass, &DelegateClass::func_VoidVoid>(&instance);
    BOOST_CHECK(channel->size() == 2);
    channel->add<DelegateClass, &DelegateClass::func_VoidVoidConst>(&instance);
    BOOST_CHECK(channel->size() == 3);
    channel->add(lambda);
    BOOST_CHECK(channel->size() == 4);

    BOOST_CHECK(channel->has<&func_VoidVoid>());
    BOOST_CHECK((channel->has<DelegateClass, &DelegateClass::func_VoidVoid>(&instance)));
    BOOST_CHECK((channel->has<DelegateClass, &DelegateClass::func_VoidVoidConst>(&instance)));
    BOOST_CHECK(channel->has(lambda));

    channel->remove<&func_VoidVoid>();
    BOOST_CHECK(channel->size() == 3);
    channel->remove<DelegateClass, &DelegateClass::func_VoidVoid>(&instance);
    BOOST_CHECK(channel->size() == 2);
    channel->remove<DelegateClass, &DelegateClass::func_VoidVoidConst>(&instance);
    BOOST_CHECK(channel->size() == 1);
    channel->remove(lambda);
    BOOST_CHECK(channel->size() == 0);

    BOOST_CHECK(!channel->has<&func_VoidVoid>());
    BOOST_CHECK((!channel->has<DelegateClass, &DelegateClass::func_VoidVoid>(&instance)));
    BOOST_CHECK((!channel->has<DelegateClass, &DelegateClass::func_VoidVoidConst>(&instance)));
    BOOST_CHECK(!channel->has(lambda));
}

BOOST_AUTO_TEST_CASE(add_to_channel_max_assert)
{
    auto channel1 = event.makeChannel(1);
    channel1->add<&func_VoidVoid>();

    auto lambda = [&](){channel1->add<&func_VoidVoid>();};
    FS_REQUIRE_ASSERT(lambda);
}

BOOST_AUTO_TEST_CASE(add_channel_to_event_and_signal_and_remove)
{
    auto channel1 = event.makeChannel(10);
    BOOST_CHECK(!event.has<&func_VoidVoid>());
    BOOST_CHECK(event.has(channel1));

    channel1->add<&func_VoidVoid>();
    BOOST_CHECK(event.has<&func_VoidVoid>());

    auto lambda1 = [&](){event.remove<&func_VoidVoid>();};
    FS_REQUIRE_ASSERT(lambda1); // cannot remove from event, must remove from channel.

    auto lambda2 = [&](){event();};
    FS_REQUIRE_ASSERT(lambda2);

    channel1->remove<&func_VoidVoid>();
    BOOST_CHECK(event.has(channel1));
    BOOST_CHECK(!event.has<&func_VoidVoid>());

    event.remove(channel1);
    BOOST_CHECK(!event.has(channel1));
}

BOOST_AUTO_TEST_CASE(add_to_event_and_signal_and_remove)
{
    BOOST_CHECK(!event.has<&func_VoidVoid>());
    event.add<&func_VoidVoid>();
    BOOST_CHECK(event.has<&func_VoidVoid>());

    auto lambda2 = [&](){event();};
    FS_REQUIRE_ASSERT(lambda2);
    BOOST_CHECK(event.has<&func_VoidVoid>());

    event.remove<&func_VoidVoid>();
    BOOST_CHECK(!event.has<&func_VoidVoid>());
}

// Also tests event.size() and channel.size()
BOOST_AUTO_TEST_CASE(add_to_event_and_remove_all)
{
    event.add<&func_VoidVoid>();
    event.add<DelegateClass, &DelegateClass::func_VoidVoid>(&instance);

    auto defaultSize = event.getDefaultChannel()->size();
    auto eventSize = event.size();
    BOOST_CHECK_MESSAGE(defaultSize == 2, "size is " << defaultSize);
    BOOST_CHECK_MESSAGE(eventSize == 2, "size is " << eventSize);
    event.removeAll();
    eventSize = event.size();
    BOOST_CHECK_MESSAGE(eventSize == 0, "size is " << eventSize);
}

BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()

max_stars_repo_name: hfarrow/Fissura

max_issues_repo_name: hfarrow/Fissura

max_forks_repo_name: hfarrow/Fissura