Browse Source

__1 in templates

Former-commit-id: 4ab340b05813c3e2237fc9bc270cd54a1fba8854
Alec Jacobson 9 years ago
parent
commit
c1a4428e91

+ 3 - 3
include/igl/ambient_occlusion.cpp

@@ -127,9 +127,9 @@ IGL_INLINE void igl::ambient_occlusion(
 #ifdef IGL_STATIC_LIBRARY
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
 // Explicit template specialization
 // generated by autoexplicit.sh
 // generated by autoexplicit.sh
-template void igl::ambient_occlusion<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(std::__1::function<bool (Eigen::Matrix<float, 3, 1, 0, 3, 1> const&, Eigen::Matrix<float, 3, 1, 0, 3, 1> const&)> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
+template void igl::ambient_occlusion<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(std::function<bool (Eigen::Matrix<float, 3, 1, 0, 3, 1> const&, Eigen::Matrix<float, 3, 1, 0, 3, 1> const&)> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
 // generated by autoexplicit.sh
 // generated by autoexplicit.sh
-template void igl::ambient_occlusion<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(std::__1::function<bool (Eigen::Matrix<float, 3, 1, 0, 3, 1> const&, Eigen::Matrix<float, 3, 1, 0, 3, 1> const&)> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
+template void igl::ambient_occlusion<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(std::function<bool (Eigen::Matrix<float, 3, 1, 0, 3, 1> const&, Eigen::Matrix<float, 3, 1, 0, 3, 1> const&)> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
 // generated by autoexplicit.sh
 // generated by autoexplicit.sh
-template void igl::ambient_occlusion<Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(std::__1::function<bool (Eigen::Matrix<float, 3, 1, 0, 3, 1> const&, Eigen::Matrix<float, 3, 1, 0, 3, 1> const&)> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
+template void igl::ambient_occlusion<Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(std::function<bool (Eigen::Matrix<float, 3, 1, 0, 3, 1> const&, Eigen::Matrix<float, 3, 1, 0, 3, 1> const&)> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
 #endif
 #endif

+ 24 - 5
include/igl/copyleft/cgal/closest_facet.cpp

@@ -226,6 +226,20 @@ IGL_INLINE void igl::copyleft::cgal::closest_facet(
     return process_edge_case(query_idx, f[0], f[1], I(fid, 0), orientation);
     return process_edge_case(query_idx, f[0], f[1], I(fid, 0), orientation);
   };
   };
 
 
+  // Given that the closest point to query point P(query_idx,:) on (V,F(I,:))
+  // is the vertex at V(s,:) which is incident at least on triangle
+  // F(preferred_facet,:), determine a facet incident on V(s,:) that is
+  // _exposed_ to the query point and determine whether that facet is facing
+  // _toward_ or _away_ from the query point.
+  //
+  // Inputs:
+  //   query_idx  index into P of query point
+  //   s  index into V of closest point at vertex
+  //   preferred_facet  facet incident on s
+  // Outputs:
+  //   orientation  whether returned face is facing toward or away from
+  //     query (parity unclear)
+  // Returns face guaranteed to be "exposed" to P(query_idx,:)
   auto process_vertex_case = [&](
   auto process_vertex_case = [&](
     const size_t query_idx, 
     const size_t query_idx, 
     size_t s,
     size_t s,
@@ -238,13 +252,16 @@ IGL_INLINE void igl::copyleft::cgal::closest_facet(
     std::vector<size_t> adj_faces;
     std::vector<size_t> adj_faces;
     std::vector<size_t> adj_face_corners;
     std::vector<size_t> adj_face_corners;
     {
     {
-      // Gether adj faces to s within I.
+      // Gather adj faces to s within I.
       const auto& all_adj_faces = VF[s];
       const auto& all_adj_faces = VF[s];
       const auto& all_adj_face_corners = VFi[s];
       const auto& all_adj_face_corners = VFi[s];
       const size_t num_all_adj_faces = all_adj_faces.size();
       const size_t num_all_adj_faces = all_adj_faces.size();
-      for (size_t i=0; i<num_all_adj_faces; i++) {
+      for (size_t i=0; i<num_all_adj_faces; i++) 
+      {
         const size_t fid = all_adj_faces[i];
         const size_t fid = all_adj_faces[i];
-        if (in_I[fid]) {
+        // Shouldn't this always be true if I is a full connected component?
+        if (in_I[fid]) 
+        {
           adj_faces.push_back(fid);
           adj_faces.push_back(fid);
           adj_face_corners.push_back(all_adj_face_corners[i]);
           adj_face_corners.push_back(all_adj_face_corners[i]);
         }
         }
@@ -255,7 +272,8 @@ IGL_INLINE void igl::copyleft::cgal::closest_facet(
 
 
     std::set<size_t> adj_vertices_set;
     std::set<size_t> adj_vertices_set;
     std::unordered_multimap<size_t, size_t> v2f;
     std::unordered_multimap<size_t, size_t> v2f;
-    for (size_t i=0; i<num_adj_faces; i++) {
+    for (size_t i=0; i<num_adj_faces; i++) 
+    {
       const size_t fid = adj_faces[i];
       const size_t fid = adj_faces[i];
       const size_t cid = adj_face_corners[i];
       const size_t cid = adj_face_corners[i];
       const auto& f = F.row(adj_faces[i]);
       const auto& f = F.row(adj_faces[i]);
@@ -271,7 +289,8 @@ IGL_INLINE void igl::copyleft::cgal::closest_facet(
         adj_vertices.begin());
         adj_vertices.begin());
 
 
     std::vector<Point_3> adj_points;
     std::vector<Point_3> adj_points;
-    for (size_t vid : adj_vertices) {
+    for (size_t vid : adj_vertices) 
+    {
       adj_points.emplace_back(V(vid,0), V(vid,1), V(vid,2));
       adj_points.emplace_back(V(vid,0), V(vid,1), V(vid,2));
     }
     }
 
 

+ 20 - 41
style-guidelines.html

@@ -1,38 +1,19 @@
-<!DOCTYPE html>
-<html>
-<head>
-	<meta charset="utf-8"/>
-	<title>libigl</title>
-	<meta name="author" content="Alec Jacobson and Daniele Panozzo and others"/>
-	<link type="text/css" rel="stylesheet" href="tutorial/style.css"/>
-<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
-<link rel='stylesheet' href='http://yandex.st/highlightjs/7.3/styles/default.min.css'>
-<script src='http://yandex.st/highlightjs/7.3/highlight.min.js'></script>
-<script>hljs.initHighlightingOnLoad();</script>
-</head>
-<body>
-
 <h1 id="libiglstyleguidelines">Libigl Style Guidelines</h1>
 <h1 id="libiglstyleguidelines">Libigl Style Guidelines</h1>
 
 
-<p>This library is shared by many people. This document highlights some style
-guidelines for <em>developers</em> of the library, but also act as best-practices for
-users.</p>
-
-<blockquote>
-<p>This is still a work in progress and will likely grow in the near future.</p>
-</blockquote>
+<p>Libigl is used and developed by many people. This document highlights some
+style guidelines for <em>developers</em> of the library, but also acts as
+best-practices for users.</p>
 
 
 <h2 id="filefunction">One function, one .h/.cpp pair</h2>
 <h2 id="filefunction">One function, one .h/.cpp pair</h2>
 
 
 <p>The structure of libigl is very flat and function-based. For every
 <p>The structure of libigl is very flat and function-based. For every
-function/sub-routine create a single .h and .cpp file. For example, if you have
+function/sub-routine, create a single .h and .cpp file. For example, if you have
 a function that determines connected components from a face list <code>F</code> you would
 a function that determines connected components from a face list <code>F</code> you would
 create the header <code>connected_components.h</code> and <code>connected_components.cpp</code> and the only
 create the header <code>connected_components.h</code> and <code>connected_components.cpp</code> and the only
 function defined should be <code>void connected_components(const ... F, ... C)</code>. If the
 function defined should be <code>void connected_components(const ... F, ... C)</code>. If the
 implementation of <code>connected_components</code> requires a subroutine to compute an
 implementation of <code>connected_components</code> requires a subroutine to compute an
 adjacency matrix then <em>create another pair</em> <code>adjacency_matrix.h</code> and
 adjacency matrix then <em>create another pair</em> <code>adjacency_matrix.h</code> and
-<code>adjacency_matrix.cpp</code> with a single function <code>void adjacency_matrix(const ... F, ...
-A)</code>.</p>
+<code>adjacency_matrix.cpp</code> with a single function <code>void adjacency_matrix(const ... F, ... A)</code>.</p>
 
 
 <h3 id="example">Example</h3>
 <h3 id="example">Example</h3>
 
 
@@ -111,7 +92,10 @@ new pair of .h/.cpp files with this sub-function.</p>
 
 
 <p>If encapsulation in a separate file is not possible or does not make sense,
 <p>If encapsulation in a separate file is not possible or does not make sense,
 then avoid crowding the namespace by creating lambda functions within the
 then avoid crowding the namespace by creating lambda functions within the
-function implmentation.</p>
+function implementation.</p>
+
+<p>These lambda functions must still be documented with clear <a href="#header-documentation">input and output
+arguments</a>.</p>
 
 
 <h3 id="avoidhelperclasses">Avoid &#8220;helper&#8221; classes</h3>
 <h3 id="avoidhelperclasses">Avoid &#8220;helper&#8221; classes</h3>
 
 
@@ -129,16 +113,16 @@ header file. A typical documentation consists of four parts:</p>
 <pre><code class="cpp">// [A human readable description of what the function does.]
 <pre><code class="cpp">// [A human readable description of what the function does.]
 //
 //
 // Inputs:
 // Inputs:
-//   [variable name of first (const) input]   [dimensions and
-//     description of this input variable]
-//   [variable name of second (const) input]   [dimensions and
-//     description of this input variable]
+//   [variable name of first (const) input]   [dimensions and description of
+//     this input variable]
+//   [variable name of second (const) input]   [dimensions and description of
+//     this input variable]
 //   ...
 //   ...
 // Outputs:
 // Outputs:
-//   [variable name of first output ]   [dimensions and
-//     description of this output variable]
-//   [variable name of second output ]   [dimensions and
-//     description of this output variable]
+//   [variable name of first output ]   [dimensions and description of this
+//     output variable]
+//   [variable name of second output ]   [dimensions and description of this
+//     output variable]
 //   ...
 //   ...
 // Returns [description of return value]
 // Returns [description of return value]
 </code></pre>
 </code></pre>
@@ -150,10 +134,10 @@ header file. A typical documentation consists of four parts:</p>
 <pre><code>// Computes the barycenter of every simplex
 <pre><code>// Computes the barycenter of every simplex
 //
 //
 // Inputs:
 // Inputs:
-//   V  #V x dim matrix of vertex coordinates
-//   F  #F x simplex_size  matrix of indices of simplex corners into V
+//   V  #V by dim matrix of vertex coordinates
+//   F  #F by simplex_size  matrix of indices of simplex corners into V
 // Output:
 // Output:
-//   BC  #F x dim matrix of 3d vertices
+//   BC  #F by dim matrix of 3d vertices
 //
 //
 </code></pre>
 </code></pre>
 
 
@@ -309,8 +293,3 @@ edited by you first. This means for
 
 
 <p>Whenever possible <code>#include</code> directives should be placed in the <code>.cpp</code>
 <p>Whenever possible <code>#include</code> directives should be placed in the <code>.cpp</code>
 implementation file rather than the <code>.h</code> header file.</p>
 implementation file rather than the <code>.h</code> header file.</p>
-
-<h2 id="eigentemplates">Eigen templates</h2>
-
-</body>
-</html>