// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2015 Alec Jacobson // // 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 "is_vertex_manifold.h" #include "triangle_triangle_adjacency.h" #include "vertex_triangle_adjacency.h" #include "unique.h" #include #include #include #include #include template IGL_INLINE bool igl::is_vertex_manifold( const Eigen::MatrixBase& F, Eigen::PlainObjectBase& B) { assert(F.cols() == 3 && "F must contain triangles"); typedef typename DerivedF::Scalar Index; using FIndex = int; const Index n = F.maxCoeff()+1; std::vector > > TT; std::vector > > TTi; triangle_triangle_adjacency(F,TT,TTi); std::vector > V2F,_1; vertex_triangle_adjacency(n,F,V2F,_1); const auto & check_vertex = [&](const Index v)->bool { std::vector uV2Fv; { std::vector _1,_2; unique(V2F[v],uV2Fv,_1,_2); } const FIndex one_ring_size = uV2Fv.size(); if(one_ring_size == 0) { return false; } const FIndex g = uV2Fv[0]; std::queue Q; Q.push(g); std::map seen; while(!Q.empty()) { const FIndex f = Q.front(); Q.pop(); if(seen.count(f)==1) { continue; } seen[f] = true; // Face f's neighbor lists opposite opposite each corner for(const auto & c : TT[f]) { // Each neighbor for(const auto & n : c) { bool contains_v = false; for(Index nc = 0;nc IGL_INLINE bool igl::is_vertex_manifold( const Eigen::MatrixBase& F) { Eigen::Array B; return is_vertex_manifold(F,B); } #ifdef IGL_STATIC_LIBRARY template bool igl::is_vertex_manifold, Eigen::Matrix >( Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&); template bool igl::is_vertex_manifold, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&); template bool igl::is_vertex_manifold>(Eigen::MatrixBase> const&); #endif