Procházet zdrojové kódy

Added tie breaker on exterior face using index.

Former-commit-id: e03a46d21767b789a923a5800eb47076943febee
Qingnan Zhou před 9 roky
rodič
revize
43881b188e
1 změnil soubory, kde provedl 7 přidání a 1 odebrání
  1. 7 1
      include/igl/exterior_element.cpp

+ 7 - 1
include/igl/exterior_element.cpp

@@ -179,7 +179,7 @@ IGL_INLINE void igl::exterior_facet(
     //    Compute the exterior edge.
     //    Find the facet with the largest absolute X normal component.
     //    If there is a tie, keep the one with positive X component.
-    //    If there is still a tie, just pick first candidate.
+    //    If there is still a tie, pick the face with the larger index.
     typedef typename DerivedV::Scalar Scalar;
     typedef typename DerivedV::Index Index;
     const size_t INVALID = std::numeric_limits<size_t>::max();
@@ -210,6 +210,12 @@ IGL_INLINE void igl::exterior_facet(
             } else if (nx == -max_nx && nx > 0) {
                 max_nx = nx;
                 exterior_fid = fid;
+            } else if (nx == max_nx) {
+                if ((max_nx >= 0 && exterior_fid < fid) ||
+                    (max_nx <  0 && exterior_fid > fid)) {
+                    max_nx = nx;
+                    exterior_fid = fid;
+                }
             }
         }
     }