浏览代码

identify 'ears' on mesh

Former-commit-id: f3a708441f8e37c94b2c29aa8c98c97b4a039084
Alec Jacobson 8 年之前
父节点
当前提交
ec0cb390f5
共有 2 个文件被更改,包括 57 次插入0 次删除
  1. 27 0
      include/igl/ears.cpp
  2. 30 0
      include/igl/ears.h

+ 27 - 0
include/igl/ears.cpp

@@ -0,0 +1,27 @@
+#include "ears.h"
+#include "on_boundary.h"
+#include "find.h"
+#include "mat_min.h"
+#include <cassert>
+
+template <
+  typename DerivedF,
+  typename Derivedear,
+  typename Derivedear_opp>
+IGL_INLINE void igl::ears(
+  const Eigen::MatrixBase<DerivedF> & F,
+  Eigen::PlainObjectBase<Derivedear> & ear,
+  Eigen::PlainObjectBase<Derivedear_opp> & ear_opp)
+{
+  assert(F.cols() == 3 && "F should contain triangles");
+  Eigen::Array<bool,Eigen::Dynamic,3> B;
+  {
+    Eigen::Array<bool,Eigen::Dynamic,1> I;
+    on_boundary(F,I,B);
+  }
+  find(B.rowwise().count() == 2,ear);
+  Eigen::Array<bool,Eigen::Dynamic,3> Bear;
+  slice(B,ear,1,Bear);
+  Eigen::Array<bool,Eigen::Dynamic,1> M;
+  mat_min(Bear,2,M,ear_opp);
+}

+ 30 - 0
include/igl/ears.h

@@ -0,0 +1,30 @@
+#ifndef IGL_EARS_H
+#define IGL_EARS_H
+#include "igl_inline.h"
+#include <Eigen/Core>
+namespace igl
+{
+  // FIND_EARS  Find all ears (faces with two boundary edges) in a given mesh
+  // 
+  // [ears,ear_opp] = find_ears(F)
+  //
+  // Inputs:
+  //   F  #F by 3 list of triangle mesh indices
+  // Outputs:
+  //   ears  #ears list of indices into F of ears
+  //   ear_opp  #ears list of indices indicating which edge is non-boundary
+  //     (connecting to flops)
+  // 
+  template <
+    typename DerivedF,
+    typename Derivedear,
+    typename Derivedear_opp>
+  IGL_INLINE void ears(
+    const Eigen::MatrixBase<DerivedF> & F,
+    Eigen::PlainObjectBase<Derivedear> & ear,
+    Eigen::PlainObjectBase<Derivedear_opp> & ear_opp);
+}
+#ifndef IGL_STATIC_LIBRARY
+#  include "ears.cpp"
+#endif
+#endif