diff --git a/toonz/sources/include/tcg/algorithm.h b/toonz/sources/include/tcg/algorithm.h deleted file mode 100644 index 2e59dde..0000000 --- a/toonz/sources/include/tcg/algorithm.h +++ /dev/null @@ -1,180 +0,0 @@ -#pragma once - -#ifndef TCG_ALGORITHM_H -#define TCG_ALGORITHM_H - -// tcg includes -#include "traits.h" - -// STD includes -#include - -/*! - \file algorithm.h - - \brief This file contains useful algorithms complementary to those - in the standard \p \ and in \p boost::algorithm. -*/ - -namespace tcg { - -//*************************************************************************** -// Binary find algorithms -//*************************************************************************** - -/*! - \brief Performs a binary search for the a value in a sorted, - random access iterators range, and returns its position. - - \return The \a first range position whose value is \a equivalent to - the specified one. -*/ -template -RanIt binary_find(RanIt begin, //!< Start of the sorted range. - RanIt end, //!< End of the sorted range. - const T &value) //!< Value to look up. -{ - RanIt it = std::lower_bound(begin, end, value); - return (it != end && !(value < *it)) ? it : end; -} - -//--------------------------------------------------------------------- - -/*! - \brief Performs a binary search for the a value in a sorted, - random access iterators range, and returns its position. - - \return The \a first range position whose value is \a equivalent to - the specified one. -*/ -template -RanIt binary_find(RanIt begin, //!< Start of the sorted range. - RanIt end, //!< End of the sorted range. - const T &value, //!< Value to look up. - Compare comp) //!< Comparator functor sorting the range. -{ - RanIt it = std::lower_bound(begin, end, value, comp); - return (it != end && !comp(value, *it)) ? it : end; -} - -//*************************************************************************** -// Min/Max iterator range algorithms -//*************************************************************************** - -/*! - \brief Calculates the minimal transformed element from the - input iterators range. - - \return The position of the minimal transform. - - \details This function is similar to std::min_element(), but - operating a unary transforming function on dereferenced - objects. - - Furthermore, the minimal transformed value is cached - during computation. -*/ -template -ForIt min_transform( - ForIt begin, //!< Start of the input iterators range. - ForIt end, //!< End of the input iterators range. - Func func, //!< The transforming function. - Comp comp) //!< The comparator object for transformed values. -{ - typedef typename tcg::function_traits::ret_type ret_type; - typedef typename tcg::remove_cref::type value_type; - - if (begin == end) return end; - - ForIt minPos = begin; - value_type minimum = func(*begin); - - for (; begin != end; ++begin) { - const value_type &candidate = func(*begin); - - if (comp(candidate, minimum)) minPos = begin, minimum = candidate; - } - - return minPos; -} - -//--------------------------------------------------------------------- - -/*! - \brief Calculates the minimal transformed element from the - input iterators range. - - \return The position of the minimal transform. - - \remark This variation uses \p operator< as comparator for the - transformed values. -*/ -template -ForIt min_transform(ForIt begin, //!< Start of the input iterators range. - ForIt end, //!< End of the input iterators range. - Func func) //!< The transforming function. -{ - typedef typename tcg::function_traits::ret_type ret_type; - typedef typename tcg::remove_cref::type value_type; - - return min_transform(begin, end, func, std::less()); -} - -//--------------------------------------------------------------------- - -/*! - \brief Calculates the maximal transformed element from the - input iterators range. - - \return The position of the maximal transform. - - \sa See min_transform() for a detailed explanation. -*/ -template -ForIt max_transform( - ForIt begin, //!< Start of the input iterators range. - ForIt end, //!< End of the input iterators range. - Func func, //!< The transforming function. - Comp comp) //!< The comparator object for transformed values. -{ - typedef typename tcg::function_traits::ret_type ret_type; - typedef typename tcg::remove_cref::type value_type; - - if (begin == end) return end; - - ForIt maxPos = begin; - value_type maximum = func(*begin); - - for (; begin != end; ++begin) { - const value_type &candidate = func(*begin); - - if (comp(maximum, candidate)) maxPos = begin, maximum = candidate; - } - - return maxPos; -} - -//--------------------------------------------------------------------- - -/*! - \brief Calculates the maximal transformed element from the - input iterators range. - - \return The position of the maximal transform. - - \sa See min_transform() for a detailed explanation. -*/ -template -ForIt max_transform(ForIt begin, //!< Start of the input iterators range. - ForIt end, //!< End of the input iterators range. - Func func) //!< The transforming function. -{ - typedef typename tcg::function_traits::ret_type ret_type; - typedef typename tcg::remove_cref::type value_type; - - return max_transform(begin, end, func, std::less()); -} - -} // namespace tcg - -#endif // TCG_ALGORITHM_H diff --git a/toonz/sources/include/tcg/tcg_algorithm.h b/toonz/sources/include/tcg/tcg_algorithm.h deleted file mode 100644 index 7a4ccf6..0000000 --- a/toonz/sources/include/tcg/tcg_algorithm.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#include "algorithm.h" diff --git a/toonz/sources/tnztools/plastictool_build.cpp b/toonz/sources/tnztools/plastictool_build.cpp index 23cb72a..f1a569d 100644 --- a/toonz/sources/tnztools/plastictool_build.cpp +++ b/toonz/sources/tnztools/plastictool_build.cpp @@ -14,7 +14,6 @@ // tcg includes #include "tcg/tcg_point_ops.h" -#include "tcg/tcg_algorithm.h" #include "tcg/tcg_function_types.h" #include "tcg/tcg_iterator_ops.h" @@ -68,20 +67,17 @@ TPointD closestMeshVertexPos(const TPointD &pos, double *distance = 0) { //------------------------------------------------------------------------ TPointD closestSkeletonVertexPos(const TPointD &pos) { - struct locals { - static inline double dist2(const TPointD &pos, - const PlasticSkeletonVertex &vx) { - return tcg::point_ops::dist2(pos, vx.P()); - } - }; - const PlasticSkeletonP &skeleton = l_plasticTool.skeleton(); if (!skeleton || skeleton->empty()) return TConsts::napd; const PlasticSkeleton::vertices_container &vertices = skeleton->vertices(); - return tcg::min_transform(vertices.begin(), vertices.end(), - tcg::bind1st(&locals::dist2, pos)) + return std::min_element(vertices.begin(), vertices.end(), + [&pos](PlasticSkeleton::vertex_type const &x, + PlasticSkeleton::vertex_type const &y) { + return tcg::point_ops::dist2(pos, x.P()) < + tcg::point_ops::dist2(pos, y.P()); + }) ->P(); } diff --git a/toonz/sources/toonz/loadfoldercommand.cpp b/toonz/sources/toonz/loadfoldercommand.cpp index 950d518..1e82ed8 100644 --- a/toonz/sources/toonz/loadfoldercommand.cpp +++ b/toonz/sources/toonz/loadfoldercommand.cpp @@ -31,7 +31,6 @@ #include // tcg includes -#include "tcg/tcg_algorithm.h" #include "tcg/tcg_function_types.h" // boost includes