Browse Source

committed missing files

Former-commit-id: 24cd0daf76f0be47d3f54fb3e4baa68192adeb6e
Daniele Panozzo 11 years ago
parent
commit
1f9a88dcef

+ 49 - 0
include/igl/add_barycenter.cpp

@@ -0,0 +1,49 @@
+#include "add_barycenter.h"
+
+#include "verbose.h"
+#include <algorithm>
+#include <igl/barycenter.h>
+
+template <typename Scalar, typename Index>
+IGL_INLINE void igl::add_barycenter(
+    const Eigen::PlainObjectBase<Scalar> & V, 
+    const Eigen::PlainObjectBase<Index> & F, 
+    Eigen::PlainObjectBase<Scalar> & VD, 
+    Eigen::PlainObjectBase<Index> & FD)
+{
+	// Compute face barycenter
+	Eigen::MatrixXd BC;
+	igl::barycenter(V,F,BC);
+
+	// Add the barycenters to the vertices
+	VD.resize(V.rows()+F.rows(),3);
+	VD.block(0,0,V.rows(),3) = V;
+	VD.block(V.rows(),0,F.rows(),3) = BC;
+
+	// Each face is split four ways
+	FD.resize(F.rows()*3,3);
+
+	for (unsigned i=0; i<F.rows(); ++i)
+	{
+		int i0 = F(i,0);
+		int i1 = F(i,1);
+		int i2 = F(i,2);
+		int i3 = V.rows() + i;
+
+		Vector3i F0,F1,F2;
+		F0 << i0,i1,i3;
+		F1 << i1,i2,i3;
+		F2 << i2,i0,i3;
+
+		FD.row(i*3 + 0) = F0;
+		FD.row(i*3 + 1) = F1;
+		FD.row(i*3 + 2) = F2;
+	}
+
+
+}
+
+
+#ifndef IGL_HEADER_ONLY
+// Explicit template specialization
+#endif

+ 31 - 0
include/igl/add_barycenter.h

@@ -0,0 +1,31 @@
+#ifndef IGL_DUAL_MESH_LIST_H
+#define IGL_DUAL_MESH_LIST_H
+#include "igl_inline.h"
+
+#include <Eigen/Dense>
+
+namespace igl 
+{
+  // Refine the mesh by adding the barycenter of each face
+  // Inputs:
+  //   V       #V by 3 coordinates of the vertices
+  //   F       #F by 3 list of mesh faces (must be triangles)
+  // Outputs: 
+  //   VD      #V + #F by 3 coordinate of the vertices of the dual mesh
+  //           The added vertices are added at the end of VD
+  //   FD      #F*3 by 3 faces of the dual mesh
+  //
+  template <typename Scalar, typename Index>
+  IGL_INLINE void add_barycenter(
+    const Eigen::PlainObjectBase<Scalar> & V, 
+    const Eigen::PlainObjectBase<Index> & F, 
+    Eigen::PlainObjectBase<Scalar> & VD, 
+    Eigen::PlainObjectBase<Index> & FD);
+
+}
+
+#ifdef IGL_HEADER_ONLY
+#  include "add_barycenter.cpp"
+#endif
+
+#endif

+ 37 - 0
include/igl/avg_edge_length.cpp

@@ -0,0 +1,37 @@
+#include "read_eigen_from_CSV.h"
+
+#include <sstream>
+#include <string>
+#include <fstream>
+
+#include <vector>
+
+namespace igl
+{
+
+  template <typename DerivedV, typename DerivedF>
+  double avg_edge_length(
+    const Eigen::PlainObjectBase<DerivedV>& V,
+    const Eigen::PlainObjectBase<DerivedF>& F)
+  {
+    double avg = 0;
+    long int count = 0;
+
+    for (unsigned i=0;i<F.rows();++i)
+    {
+      for (unsigned j=0;j<3;++j)
+      {
+        ++count;
+        avg += (V.row(F(i,j)) - V.row(F(i,(j+1)%3))).norm();
+      }
+    }
+
+    return avg / (double) count;
+  }
+
+}
+
+#ifndef IGL_HEADER_ONLY
+// Explicit template specialization
+// generated by autoexplicit.sh
+#endif

+ 34 - 0
include/igl/avg_edge_length.h

@@ -0,0 +1,34 @@
+#ifndef IGL_AVERAGEEDGELENGTH_H
+#define IGL_AVERAGEEDGELENGTH_H
+
+#include "igl/igl_inline.h"
+#include <Eigen/Core>
+#include <string>
+#include <vector>
+
+namespace igl 
+{
+  // Compute the average edge length for the given triangle mesh
+  // Templates:
+  //   DerivedV derived from vertex positions matrix type: i.e. MatrixXd
+  //   DerivedF derived from face indices matrix type: i.e. MatrixXi
+  //   DerivedL derived from edge lengths matrix type: i.e. MatrixXd
+  // Inputs:
+  //   V  eigen matrix #V by 3
+  //   F  #F by 3 list of mesh faces (must be triangles)
+  // Outputs:
+  //   l  average edge length
+  //
+  // See also: adjacency_matrix
+  template <typename DerivedV, typename DerivedF>
+  IGL_INLINE double avg_edge_length(
+    const Eigen::PlainObjectBase<DerivedV>& V,
+    const Eigen::PlainObjectBase<DerivedF>& F);
+
+}
+
+//#ifdef IGL_HEADER_ONLY
+#  include "avg_edge_length.cpp"
+//#endif
+
+#endif