[Bf-blender-cvs] [2f86198cee] uv_unwrapping_slim_algorithm: Implementation of UV unwrapping with SLIM as disdussed on T48036.

Aurel Gruber noreply at git.blender.org
Mon Feb 27 14:16:44 CET 2017


Commit: 2f86198cee8acc74379569ba91e371156ed0e0b9
Author: Aurel Gruber
Date:   Fri Feb 24 09:31:38 2017 +0100
Branches: uv_unwrapping_slim_algorithm
https://developer.blender.org/rB2f86198cee8acc74379569ba91e371156ed0e0b9

Implementation of UV unwrapping with SLIM as disdussed on T48036.

commits:

Category: UV Unwrapping SLIM Algorithm Integration

Added SLIM Subfolder

Category: UV Unwrapping SLIM Algorithm Integration

added subfolder SLIM to CMakeFile of /intern

Category: UV Unwrapping SLIM Algorithm Integration

integrating SLIM including data gathering and transfer from Blender to SLIM

This commit is huge, because I copied over the code from a different repository. Not commit-by-commit.

The Algorithm can be invoked either by choosing SLIM from the dropdown in the unwrapping settings or by
hitting ctrl. + m in the uv editor for relaxation. Tried adding it to the menu the same way as minimizing stretch is there but failed.

Category: UV Unwrapping SLIM Algorithm Integration

preserving vertex ids and gathering weights

Category: UV Unwrapping SLIM Algorithm Integration

adding more members to phandle and creating param_begin

Category: UV Unwrapping SLIM Algorithm Integration

fixing bug that causes weight-per-vertex mapping to be wrong

Category: UV Unwrapping SLIM Algorithm Integration

adjustments to the UI parameters

Category: UV Unwrapping SLIM Algorithm Integration

adding weightinfluence

Category: UV Unwrapping SLIM Algorithm Integration

slim interactive exec now only for changing parameters

Category: UV Unwrapping SLIM Algorithm Integration

taking care of memory leaks

Category: UV Unwrapping SLIM Algorithm Integration

adding relative scale, reflection mode and Vertex group input

Category: UV Unwrapping SLIM Algorithm Integration

correcting wrong comment on SLIM phases

Category: UV Unwrapping SLIM Algorithm Integration

Adding SLIM code by means of git read-tree

Category: UV Unwrapping SLIM Algorithm Integration

freeing matrix_transfer properly

Category: UV Unwrapping SLIM Algorithm Integration

adding (unsupported-) eigen files

Reviewers: brecht, sergey

Differential Revision: https://developer.blender.org/D2530

===================================================================

A	extern/Eigen3/unsupported/Eigen/AdolcForward
A	extern/Eigen3/unsupported/Eigen/AlignedVector3
A	extern/Eigen3/unsupported/Eigen/ArpackSupport
A	extern/Eigen3/unsupported/Eigen/AutoDiff
A	extern/Eigen3/unsupported/Eigen/BVH
A	extern/Eigen3/unsupported/Eigen/CMakeLists.txt
A	extern/Eigen3/unsupported/Eigen/FFT
A	extern/Eigen3/unsupported/Eigen/IterativeSolvers
A	extern/Eigen3/unsupported/Eigen/KroneckerProduct
A	extern/Eigen3/unsupported/Eigen/LevenbergMarquardt
A	extern/Eigen3/unsupported/Eigen/MPRealSupport
A	extern/Eigen3/unsupported/Eigen/MatrixFunctions
A	extern/Eigen3/unsupported/Eigen/MoreVectorization
A	extern/Eigen3/unsupported/Eigen/NonLinearOptimization
A	extern/Eigen3/unsupported/Eigen/NumericalDiff
A	extern/Eigen3/unsupported/Eigen/OpenGLSupport
A	extern/Eigen3/unsupported/Eigen/Polynomials
A	extern/Eigen3/unsupported/Eigen/SVD
A	extern/Eigen3/unsupported/Eigen/Skyline
A	extern/Eigen3/unsupported/Eigen/SparseExtra
A	extern/Eigen3/unsupported/Eigen/Splines
A	extern/Eigen3/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h
A	extern/Eigen3/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h
A	extern/Eigen3/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h
A	extern/Eigen3/unsupported/Eigen/src/AutoDiff/CMakeLists.txt
A	extern/Eigen3/unsupported/Eigen/src/BVH/BVAlgorithms.h
A	extern/Eigen3/unsupported/Eigen/src/BVH/CMakeLists.txt
A	extern/Eigen3/unsupported/Eigen/src/BVH/KdBVH.h
A	extern/Eigen3/unsupported/Eigen/src/CMakeLists.txt
A	extern/Eigen3/unsupported/Eigen/src/Eigenvalues/ArpackSelfAdjointEigenSolver.h
A	extern/Eigen3/unsupported/Eigen/src/Eigenvalues/CMakeLists.txt
A	extern/Eigen3/unsupported/Eigen/src/FFT/CMakeLists.txt
A	extern/Eigen3/unsupported/Eigen/src/FFT/ei_fftw_impl.h
A	extern/Eigen3/unsupported/Eigen/src/FFT/ei_kissfft_impl.h
A	extern/Eigen3/unsupported/Eigen/src/IterativeSolvers/CMakeLists.txt
A	extern/Eigen3/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h
A	extern/Eigen3/unsupported/Eigen/src/IterativeSolvers/DGMRES.h
A	extern/Eigen3/unsupported/Eigen/src/IterativeSolvers/GMRES.h
A	extern/Eigen3/unsupported/Eigen/src/IterativeSolvers/IncompleteCholesky.h
A	extern/Eigen3/unsupported/Eigen/src/IterativeSolvers/IncompleteLU.h
A	extern/Eigen3/unsupported/Eigen/src/IterativeSolvers/IterationController.h
A	extern/Eigen3/unsupported/Eigen/src/IterativeSolvers/MINRES.h
A	extern/Eigen3/unsupported/Eigen/src/IterativeSolvers/Scaling.h
A	extern/Eigen3/unsupported/Eigen/src/KroneckerProduct/CMakeLists.txt
A	extern/Eigen3/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h
A	extern/Eigen3/unsupported/Eigen/src/LevenbergMarquardt/CMakeLists.txt
A	extern/Eigen3/unsupported/Eigen/src/LevenbergMarquardt/CopyrightMINPACK.txt
A	extern/Eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMcovar.h
A	extern/Eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMonestep.h
A	extern/Eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMpar.h
A	extern/Eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMqrsolv.h
A	extern/Eigen3/unsupported/Eigen/src/LevenbergMarquardt/LevenbergMarquardt.h
A	extern/Eigen3/unsupported/Eigen/src/MatrixFunctions/CMakeLists.txt
A	extern/Eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h
A	extern/Eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h
A	extern/Eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixFunctionAtomic.h
A	extern/Eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h
A	extern/Eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h
A	extern/Eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixSquareRoot.h
A	extern/Eigen3/unsupported/Eigen/src/MatrixFunctions/StemFunction.h
A	extern/Eigen3/unsupported/Eigen/src/MoreVectorization/CMakeLists.txt
A	extern/Eigen3/unsupported/Eigen/src/MoreVectorization/MathFunctions.h
A	extern/Eigen3/unsupported/Eigen/src/NonLinearOptimization/CMakeLists.txt
A	extern/Eigen3/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h
A	extern/Eigen3/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h
A	extern/Eigen3/unsupported/Eigen/src/NonLinearOptimization/chkder.h
A	extern/Eigen3/unsupported/Eigen/src/NonLinearOptimization/covar.h
A	extern/Eigen3/unsupported/Eigen/src/NonLinearOptimization/dogleg.h
A	extern/Eigen3/unsupported/Eigen/src/NonLinearOptimization/fdjac1.h
A	extern/Eigen3/unsupported/Eigen/src/NonLinearOptimization/lmpar.h
A	extern/Eigen3/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h
A	extern/Eigen3/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h
A	extern/Eigen3/unsupported/Eigen/src/NonLinearOptimization/r1updt.h
A	extern/Eigen3/unsupported/Eigen/src/NonLinearOptimization/rwupdt.h
A	extern/Eigen3/unsupported/Eigen/src/NumericalDiff/CMakeLists.txt
A	extern/Eigen3/unsupported/Eigen/src/NumericalDiff/NumericalDiff.h
A	extern/Eigen3/unsupported/Eigen/src/Polynomials/CMakeLists.txt
A	extern/Eigen3/unsupported/Eigen/src/Polynomials/Companion.h
A	extern/Eigen3/unsupported/Eigen/src/Polynomials/PolynomialSolver.h
A	extern/Eigen3/unsupported/Eigen/src/Polynomials/PolynomialUtils.h
A	extern/Eigen3/unsupported/Eigen/src/SVD/BDCSVD.h
A	extern/Eigen3/unsupported/Eigen/src/SVD/CMakeLists.txt
A	extern/Eigen3/unsupported/Eigen/src/SVD/JacobiSVD.h
A	extern/Eigen3/unsupported/Eigen/src/SVD/SVDBase.h
A	extern/Eigen3/unsupported/Eigen/src/SVD/TODOBdcsvd.txt
A	extern/Eigen3/unsupported/Eigen/src/SVD/doneInBDCSVD.txt
A	extern/Eigen3/unsupported/Eigen/src/Skyline/CMakeLists.txt
A	extern/Eigen3/unsupported/Eigen/src/Skyline/SkylineInplaceLU.h
A	extern/Eigen3/unsupported/Eigen/src/Skyline/SkylineMatrix.h
A	extern/Eigen3/unsupported/Eigen/src/Skyline/SkylineMatrixBase.h
A	extern/Eigen3/unsupported/Eigen/src/Skyline/SkylineProduct.h
A	extern/Eigen3/unsupported/Eigen/src/Skyline/SkylineStorage.h
A	extern/Eigen3/unsupported/Eigen/src/Skyline/SkylineUtil.h
A	extern/Eigen3/unsupported/Eigen/src/SparseExtra/BlockOfDynamicSparseMatrix.h
A	extern/Eigen3/unsupported/Eigen/src/SparseExtra/CMakeLists.txt
A	extern/Eigen3/unsupported/Eigen/src/SparseExtra/DynamicSparseMatrix.h
A	extern/Eigen3/unsupported/Eigen/src/SparseExtra/MarketIO.h
A	extern/Eigen3/unsupported/Eigen/src/SparseExtra/MatrixMarketIterator.h
A	extern/Eigen3/unsupported/Eigen/src/SparseExtra/RandomSetter.h
A	extern/Eigen3/unsupported/Eigen/src/Splines/CMakeLists.txt
A	extern/Eigen3/unsupported/Eigen/src/Splines/Spline.h
A	extern/Eigen3/unsupported/Eigen/src/Splines/SplineFitting.h
A	extern/Eigen3/unsupported/Eigen/src/Splines/SplineFwd.h
A	extern/Eigen3/unsupported/README.txt

===================================================================

diff --git a/extern/Eigen3/unsupported/Eigen/AdolcForward b/extern/Eigen3/unsupported/Eigen/AdolcForward
new file mode 100644
index 0000000000..2627decd0f
--- /dev/null
+++ b/extern/Eigen3/unsupported/Eigen/AdolcForward
@@ -0,0 +1,156 @@
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra.
+//
+// Copyright (C) 2008-2009 Gael Guennebaud <g.gael at free.fr>
+//
+// This Source Code Form is subject to the terms of the Mozilla
+// Public License v. 2.0. If a copy of the MPL was not distributed
+// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef EIGEN_ADLOC_FORWARD
+#define EIGEN_ADLOC_FORWARD
+
+//--------------------------------------------------------------------------------
+//
+// This file provides support for adolc's adouble type in forward mode.
+// ADOL-C is a C++ automatic differentiation library,
+// see https://projects.coin-or.org/ADOL-C for more information.
+//
+// Note that the maximal number of directions is controlled by
+// the preprocessor token NUMBER_DIRECTIONS. The default is 2.
+//
+//--------------------------------------------------------------------------------
+
+#define ADOLC_TAPELESS
+#ifndef NUMBER_DIRECTIONS
+# define NUMBER_DIRECTIONS 2
+#endif
+#include <adolc/adouble.h>
+
+// adolc defines some very stupid macros:
+#if defined(malloc)
+# undef malloc
+#endif
+
+#if defined(calloc)
+# undef calloc
+#endif
+
+#if defined(realloc)
+# undef realloc
+#endif
+
+#include <Eigen/Core>
+
+namespace Eigen {
+
+/**
+  * \defgroup AdolcForward_Module Adolc forward module
+  * This module provides support for adolc's adouble type in forward mode.
+  * ADOL-C is a C++ automatic differentiation library,
+  * see https://projects.coin-or.org/ADOL-C for more information.
+  * It mainly consists in:
+  *  - a struct Eigen::NumTraits<adtl::adouble> specialization
+  *  - overloads of internal::* math function for adtl::adouble type.
+  *
+  * Note that the maximal number of directions is controlled by
+  * the preprocessor token NUMBER_DIRECTIONS. The default is 2.
+  *
+  * \code
+  * #include <unsupported/Eigen/AdolcSupport>
+  * \endcode
+  */
+  //@{
+
+} // namespace Eigen
+
+// Eigen's require a few additional functions which must be defined in the same namespace
+// than the custom scalar type own namespace
+namespace adtl {
+
+inline const adouble& conj(const adouble& x)  { return x; }
+inline const adouble& real(const adouble& x)  { return x; }
+inline adouble imag(const adouble&)    { return 0.; }
+inline adouble abs(const adouble&  x)  { return fabs(x); }
+inline adouble abs2(const adouble& x)  { return x*x; }
+
+}
+
+namespace Eigen {
+
+template<> struct NumTraits<adtl::adouble>
+    : NumTraits<double>
+{
+  typedef adtl::adouble Real;
+  typedef adtl::adouble NonInteger;
+  typedef adtl::adouble Nested;
+  enum {
+    IsComplex = 0,
+    IsInteger = 0,
+    IsSigned = 1,
+    RequireInitialization = 1,
+    ReadCost = 1,
+    AddCost = 1,
+    MulCost = 1
+  };
+};
+
+template<typename Functor> class AdolcForwardJacobian : public Functor
+{
+  typedef adtl::adouble ActiveScalar;
+public:
+
+  AdolcForwardJacobian() : Functor() {}
+  AdolcForwardJacobian(const Functor& f) : Functor(f) {}
+
+  // forward constructors
+  template<typename T0>
+  AdolcForwardJacobian(const T0& a0) : Functor(a0) {}
+  template<typename T0, typename T1>
+  AdolcForwardJacobian(const T0& a0, const T1& a1) : Functor(a0, a1) {}
+  template<typename T0, typename T1, typename T2>
+  AdolcForwardJacobian(const T0& a0, const T1& a1, const T1& a2) : Functor(a0, a1, a2) {}
+
+  typedef typename Functor::InputType InputType;
+  typedef typename Functor::ValueType ValueType;
+  typedef typename Functor::JacobianType JacobianType;
+
+  typedef Matrix<ActiveScalar, InputType::SizeAtCompileTime, 1> ActiveInput;
+  typedef Matrix<ActiveScalar, ValueType::SizeAtCompileTime, 1> ActiveValue;
+
+  void operator() (const InputType& x, ValueType* v, JacobianType* _jac) const
+  {
+    eigen_assert(v!=0);
+    if (!_jac)
+    {
+      Functor::operator()(x, v);
+      return;
+    }
+
+    JacobianType& jac = *_jac;
+
+    ActiveInput ax = x.template cast<ActiveScalar>();
+    ActiveValue av(jac.rows());
+
+    for (int j=0; j<jac.cols(); j++)
+      for (int i=0; i<jac.cols(); i++)
+        ax[i].setADValue(j, i==j ? 1 : 0);
+
+    Functor::operator()(ax, &av);
+
+    for (int i=0; i<jac.rows(); i++)
+    {
+      (*v)[i] = av[i].getValue();
+      for (int j=0; j<jac.cols(); j++)
+        jac.coeffRef(i,j) = av[i].getADValue(j);
+    }
+  }
+protected:
+
+};
+
+//@}
+
+}
+
+#endif // EIGEN_ADLOC_FORWARD
diff --git a/extern/Eigen3/unsupported/Eigen/AlignedVector3 b/extern/Eigen3/unsupported/Eigen/AlignedVector3
new file mode 100644
index 0000000000..29d5c90fb5
--- /dev/null
+++ b/extern/Eigen3/unsupported/Eigen/AlignedVector3
@@ -0,0 +1,190 @@
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra.
+//
+// Copyright (C) 2009 Gael Guennebaud <g.gael at free.fr>
+//
+// This Source Code Form is subject to the terms of the Mozilla
+// Public License v. 2.0. If a copy of the MPL was not distributed
+// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef EIGEN_ALIGNED_VECTOR3
+#define EIGEN_ALIGNED_VECTOR3
+
+#include <Eigen/Geometry>
+
+namespace Eigen {
+
+/**
+  * \defgroup AlignedVector3_Module Aligned vector3 module
+  *
+  * \code
+  * #include <unsupported/Eigen/AlignedVector3>
+  * \endcode
+  */
+  //@{
+
+
+/** \class AlignedVector3
+  *
+  * \brief A vectorization friendly 3D vector
+  *
+  * This class represents a 3D vector internally using a 4D vector
+  * such that vectorization can be seamlessly enabled. Of course,
+  * the same result can be achieved by directly using a 4D vector.
+  * This class makes this process simpler.
+  *
+  */
+// TODO specialize Cwise
+template<typename _Scalar> class AlignedVector3;
+
+namespace internal {
+template<typename _Scalar> struct traits<AlignedVector3<_Scalar> >
+  : traits<Matrix<_Scalar,3,1,0,4,1> >
+{
+};
+}
+
+template<typename _Scalar> class AlignedVector3
+  : public MatrixBase<AlignedVector3<_Scalar> >
+{
+    typedef Matrix<_Scalar,4,1> CoeffType;
+    CoeffType m_coeffs;
+  public:
+
+    typedef MatrixBase<AlignedVector3<_Scalar> > Base;	
+    EIGEN_DENSE_PUBLIC_INTERFACE(AlignedVector3)
+    using Base::operator*;
+
+    inline Index rows() const { return 3; }
+    inline Index cols() const { return 1; }
+
+    inline const Scalar& coeff(Index row, Index col) const
+    { return m_coeffs.coeff(row, col); }
+
+    inline Scalar& coeffRef(Index row, Index col)
+    { return m_coeffs.coeffRef(row, col); }
+
+    inline const Scalar& coeff(Index index) const
+    { return m_coeffs.coeff(index); }
+
+    inline Scalar& coeffRef(Index index)
+    { return m_coeffs.coeffRef(index);}
+
+
+    inline AlignedVector3(const Scalar& x, const Scalar& y, const Scalar& z)
+      : m_coeffs(x, y, z, Scalar(0))
+    {}
+
+    inline AlignedVector3(const AlignedVector3& other)
+      : Base(), m_coeffs(other.m_coeffs)
+    {}
+
+    template<typename XprType, int Size=XprType::SizeAtCompileTime>
+    struct generic_assign_selector {};
+
+    template<typename XprType> struct generic_assign_selector<XprType,4>
+    {
+      inline static void run(AlignedVector3& dest, const XprType& src)
+      {
+        dest.m_coeffs = src;
+      }
+    };
+
+    template<typename XprType> struct generic_assign_selector<XprType,3>
+    {
+      inline static void run(AlignedVector3& dest, const XprType& src)
+      {
+        dest.m_coeffs.template head<3>() = src;
+        dest.m_coeffs.w() = Scalar(0);
+      }
+    };
+
+    template<typename Derived>
+    inline explicit AlignedVector3(const MatrixBase<Derived>& other)
+    {
+      generic_assign_selector<Derived>::run(*this,other.derived());
+    }
+
+    inline AlignedVector3& operator=(const AlignedVector3& other)
+    { m_coeffs = other.m_coeffs; return *this; }
+
+
+    inline AlignedVector3 operator+(const AlignedVector3& other) const
+    { return AlignedVector3(m_coeffs + other.m_coeffs); }
+
+    inline AlignedVector3& operator+=(const AlignedVector3& other)
+    { m_coeffs += other.m_coeffs; return *this; }
+
+    inline AlignedVector3 operator-(const AlignedVector3& other) const
+    { return AlignedVector3(m_coeffs - other.m_coeffs); }
+
+    inline AlignedVector3 operator-=(const AlignedVector3& other)
+    { m_coeffs -= other.m_coeffs; return *this; }
+
+    inline AlignedVector3 operator*(const Scalar& s) const
+    { return AlignedVector3(m_coeffs * s); }
+
+    inline friend AlignedVector3 operator*(const Scalar& s,const AlignedVector3& vec)
+    { return AlignedVector3(s * vec.m_coeffs); }
+
+    inline AlignedVector3& operator*=(const Scalar& s)
+    { m_coeffs *= s; return *this; }
+
+    inline AlignedVector3 operator/(const Scalar& s) const
+    { return AlignedVector3(m_coeffs / s); }
+
+    inline AlignedVector3& operator/=(const Scalar& s)
+    { m_coeffs /= s; return *this; }
+
+    inline Scalar dot(const AlignedVector3& other) const
+    {
+      eigen_assert(m_coeffs.w()==Scalar(0));
+      eigen_assert(other.m_coeffs.w()==Scalar(0));
+      return m_coeffs.dot(other.m_coeffs);
+    }
+
+    inline void normalize()
+    {
+      m_coeffs /= norm();
+    }
+
+    inline AlignedVector3 normalized()
+    {
+      return AlignedVector3(m_coeffs / norm());
+    }
+
+    inline Scalar sum() const
+    {
+      eigen_assert(m_coeffs.w()==Scalar(0));
+      return m_coeffs.sum();
+    }
+
+    inline Scalar squaredNorm() const
+    {
+      eigen_assert(m_coeffs.w()==Scalar(0));
+      return m_coeffs.squaredNorm();
+    }
+
+    inline Scalar norm() const
+    {
+      using std::sqrt;
+      return sqrt(squaredNorm());
+    }
+
+    inline AlignedVector3 cross(const AlignedVector3& other) const
+    {
+      return AlignedVector3(m_coeffs.cross3(other.m_coeffs));
+    }
+
+    template<typename Derived>
+    inline bool isApprox(const MatrixBase<Derived>& other, const RealScalar& eps=NumTraits<Scalar>::dummy_precision()) const
+    {
+      return m_coeffs.template head<3>().isApprox(other,eps);
+    }
+};
+
+//@}
+
+}
+
+#endif // EIGE

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list