123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- // This file is part of libigl, a simple c++ geometry processing library.
- //
- // Copyright (C) 2016 Michael Rabinovich <michaelrabinovich27@gmail.com@gmail.com>
- //
- // 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/.
- #include "flipped_triangles_ids.h"
- #include <igl/edge_topology.h>
- template <typename Scalar, typename Index>
- IGL_INLINE Eigen::VectorXi flipped_triangles_ids(
- const Eigen::PlainObjectBase<Scalar> & V,
- const Eigen::PlainObjectBase<Index> & F
- )
- {
- assert(V.cols() == 2);
- std::vector<int> flip_idx;
- for (int i = 0; i < F.rows(); i++) {
- Eigen::Vector2d v1_n = V.row(F(i,0)); Eigen::Vector2d v2_n = V.row(F(i,1)); Eigen::Vector2d v3_n = V.row(F(i,2));
- Eigen::MatrixXd T2_Homo(3,3);
- T2_Homo.col(0) << v1_n(0),v1_n(1),1;
- T2_Homo.col(1) << v2_n(0),v2_n(1),1;
- T2_Homo.col(2) << v3_n(0),v3_n(1),1;
- double det = T2_Homo.determinant();
- assert (det == det);
- if (det < 0) {
- flip_idx.push_back(i);
- }
- }
- Eigen::VectorXi ret(flip_idx.size());
- for (unsigned i=0; i<flip_idx.size();++i)
- ret[i] = flip_idx[i];
- return ret;
- }
- #ifdef IGL_STATIC_LIBRARY
- // Explicit template specialization
- // generated by autoexplicit.sh
- #endif
|