Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

Remove tcg_algorithm.h (#2435)

otakutoabc9ca2e31cd
diff --git a/toonz/sources/include/tcg/algorithm.h b/toonz/sources/include/tcg/algorithm.h
deleted file mode 100644
index 2e59dde3d..000000000
--- 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 <functional>
-
-/*!
- \file algorithm.h
-
- \brief This file contains useful algorithms complementary to those
- in the standard \p \<algorithm\> and in \p boost::algorithm.
-*/
-
-namespace tcg {
-
-//***************************************************************************
-// Binary find algorithms
-//***************************************************************************
-
-/*!
- \brief Performs a binary search for the a value in a <I>sorted,
- random access</I> iterators range, and returns its position.
-
- \return The \a first range position whose value is \a equivalent to
- the specified one.
-*/
-template <typename RanIt, typename T>
-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 <I>sorted,
- random access</I> iterators range, and returns its position.
-
- \return The \a first range position whose value is \a equivalent to
- the specified one.
-*/
-template <typename RanIt, typename T, typename Compare>
-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 <typename ForIt, typename Func, typename Comp>
-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<Func>::ret_type ret_type;
- typedef typename tcg::remove_cref<ret_type>::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 <typename ForIt, typename Func>
-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<Func>::ret_type ret_type;
- typedef typename tcg::remove_cref<ret_type>::type value_type;
-
- return min_transform(begin, end, func, std::less<value_type>());
-}
-
-//---------------------------------------------------------------------
-
-/*!
- \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 <typename ForIt, typename Func, typename Comp>
-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<Func>::ret_type ret_type;
- typedef typename tcg::remove_cref<ret_type>::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 <typename ForIt, typename Func>
-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<Func>::ret_type ret_type;
- typedef typename tcg::remove_cref<ret_type>::type value_type;
-
- return max_transform(begin, end, func, std::less<value_type>());
-}
-
-} // 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 7a4ccf6c0..000000000
--- 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 23cb72aac..f1a569dea 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 950d51812..1e82ed827 100644
--- a/toonz/sources/toonz/loadfoldercommand.cpp
+++ b/toonz/sources/toonz/loadfoldercommand.cpp
@@ -31,7 +31,6 @@
#include <QRadioButton>
// tcg includes
-#include "tcg/tcg_algorithm.h"
#include "tcg/tcg_function_types.h"
// boost includes