Преглед на файлове

Merge branch 'master' of github.com:libigl/libigl into alecjacobson

Former-commit-id: e9e637f81455ac84d238f06ae89a8e34a2890e8a
Alec Jacobson преди 8 години
родител
ревизия
6a0a6797ee
променени са 9 файла, в които са добавени 44 реда и са изтрити 17 реда
  1. 1 1
      include/igl/ply.h.REMOVED.git-id
  2. 11 9
      include/igl/readPLY.cpp
  3. 3 3
      include/igl/readPLY.h
  4. 3 2
      include/igl/writePLY.cpp
  5. 10 0
      python/py_doc.cpp
  6. 1 0
      python/py_doc.h
  7. 2 2
      python/py_igl.cpp
  8. 12 0
      python/py_igl/py_readPLY.cpp
  9. 1 0
      python/python_shared.cpp

+ 1 - 1
include/igl/ply.h.REMOVED.git-id

@@ -1 +1 @@
-0878f821fc814405b3bd8c4bdf25ce10df162e95
+e4826d12221d5fca54d3cc95e6a30cbb50fc7fe9

+ 11 - 9
include/igl/readPLY.cpp

@@ -16,7 +16,7 @@ template <
   typename Ntype,
   typename UVtype>
 IGL_INLINE bool igl::readPLY(
-  const std::string & filename,
+  const std::string filename,
   std::vector<std::vector<Vtype> > & V,
   std::vector<std::vector<Ftype> > & F,
   std::vector<std::vector<Ntype> > & N,
@@ -88,6 +88,7 @@ IGL_INLINE bool igl::readPLY(
   int nprops;
   int elem_count;
   plist = ply_get_element_description (in_ply,"vertex", &elem_count, &nprops);
+  int native_binary_type = get_native_binary_type2();
   if (plist != NULL)
   {
     /* set up for getting vertex elements */
@@ -132,11 +133,12 @@ IGL_INLINE bool igl::readPLY(
     {
       UV.resize(0);
     }
-    for(int j = 0;j<elem_count;j++)
+   	
+	for(int j = 0;j<elem_count;j++)
     {
       Vertex v;
       ply_get_element_setup(in_ply,"vertex",3,vert_props);
-      ply_get_element(in_ply,(void*)&v);
+      ply_get_element(in_ply,(void*)&v, &native_binary_type);
       V[j][0] = v.x;
       V[j][1] = v.y;
       V[j][2] = v.z;
@@ -161,7 +163,7 @@ IGL_INLINE bool igl::readPLY(
     for (int j = 0; j < elem_count; j++) 
     {
       Face f;
-      ply_get_element(in_ply, (void *) &f);
+      ply_get_element(in_ply, (void *) &f, &native_binary_type);
       for(size_t c = 0;c<f.nverts;c++)
       {
         F[j].push_back(f.verts[c]);
@@ -178,7 +180,7 @@ template <
   typename DerivedN,
   typename DerivedUV>
 IGL_INLINE bool igl::readPLY(
-  const std::string & filename,
+  const std::string filename,
   Eigen::PlainObjectBase<DerivedV> & V,
   Eigen::PlainObjectBase<DerivedF> & F,
   Eigen::PlainObjectBase<DerivedN> & N,
@@ -203,7 +205,7 @@ template <
   typename DerivedV,
   typename DerivedF>
 IGL_INLINE bool igl::readPLY(
-  const std::string & filename,
+  const std::string filename,
   Eigen::PlainObjectBase<DerivedV> & V,
   Eigen::PlainObjectBase<DerivedF> & F)
 {
@@ -213,9 +215,9 @@ IGL_INLINE bool igl::readPLY(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template instantiation
-template bool igl::readPLY<double, int, double, double>(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&);
+template bool igl::readPLY<double, int, double, double>(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&);
 
-template bool igl::readPLY<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> > &, Eigen::PlainObjectBase<Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic> > &, Eigen::PlainObjectBase<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> > &, Eigen::PlainObjectBase<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> > &);
+template bool igl::readPLY<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, Eigen::PlainObjectBase<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> > &, Eigen::PlainObjectBase<Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic> > &, Eigen::PlainObjectBase<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> > &, Eigen::PlainObjectBase<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> > &);
 
-template bool igl::readPLY<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> > &, Eigen::PlainObjectBase<Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic> > &);
+template bool igl::readPLY<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, Eigen::PlainObjectBase<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> > &, Eigen::PlainObjectBase<Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic> > &);
 #endif

+ 3 - 3
include/igl/readPLY.h

@@ -31,7 +31,7 @@ namespace igl
     typename Ntype,
     typename UVtype>
   IGL_INLINE bool readPLY(
-    const std::string & filename,
+    const std::string filename,
     std::vector<std::vector<Vtype> > & V,
     std::vector<std::vector<Ftype> > & F,
     std::vector<std::vector<Ntype> > & N,
@@ -57,7 +57,7 @@ namespace igl
     typename DerivedN,
     typename DerivedUV>
   IGL_INLINE bool readPLY(
-    const std::string & filename,
+    const std::string filename,
     Eigen::PlainObjectBase<DerivedV> & V,
     Eigen::PlainObjectBase<DerivedF> & F,
     Eigen::PlainObjectBase<DerivedN> & N,
@@ -66,7 +66,7 @@ namespace igl
     typename DerivedV,
     typename DerivedF>
   IGL_INLINE bool readPLY(
-    const std::string & filename,
+    const std::string filename,
     Eigen::PlainObjectBase<DerivedV> & V,
     Eigen::PlainObjectBase<DerivedF> & F);
 }

+ 3 - 2
include/igl/writePLY.cpp

@@ -120,15 +120,16 @@ IGL_INLINE bool igl::writePLY(
 
   ply_describe_element(ply, "face", F.rows(),1,&face_props[0]);
   ply_header_complete(ply);
+  int native_binary_type = get_native_binary_type2();
   ply_put_element_setup(ply, "vertex");
   for(const auto v : vlist)
   {
-    ply_put_element(ply, (void *) &v);
+    ply_put_element(ply, (void *) &v, &native_binary_type);
   }
   ply_put_element_setup(ply, "face");
   for(const auto f : flist)
   {
-    ply_put_element(ply, (void *) &f);
+    ply_put_element(ply, (void *) &f, &native_binary_type);
   }
 
   ply_close(ply);

+ 10 - 0
python/py_doc.cpp

@@ -1436,3 +1436,13 @@ const char *__doc_igl_writePLY = R"igl_Qu8mg5v7(// Write a mesh in an ascii ply
   //   N  #V by 3 normal vectors
   //   UV #V by 2 texture coordinates
   // Returns true on success, false on error)igl_Qu8mg5v7";
+const char *__doc_igl_readPLY= R"igl_Qu8mg5v7(// Read a mesh from an ascii ply file, filling in vertex positions,
+  // mesh indices, normals and texture coordinates
+  // Inputs:
+  //  str path to .obj file
+  // Outputs:
+  //   V  double matrix of vertex positions  #V by 3
+  //   F  #F list of face indices into vertex positions
+  //   N  double matrix of corner normals #N by 3
+  //   UV #V by 2 texture coordinates
+  // Returns true on success, false on errors)igl_Qu8mg5v7";

+ 1 - 0
python/py_doc.h

@@ -118,3 +118,4 @@ extern const char *__doc_igl_winding_number_2;
 extern const char *__doc_igl_writeMESH;
 extern const char *__doc_igl_writeOBJ;
 extern const char *__doc_igl_writePLY;
+extern const char *__doc_igl_readPLY;

+ 2 - 2
python/py_igl.cpp

@@ -94,7 +94,7 @@
 #include <igl/writeMESH.h>
 #include <igl/writeOBJ.h>
 #include <igl/writePLY.h>
-
+#include <igl/readPLY.h>
 
 void python_export_igl(py::module &m)
 {
@@ -191,5 +191,5 @@ void python_export_igl(py::module &m)
 #include "py_igl/py_writeMESH.cpp"
 #include "py_igl/py_writeOBJ.cpp"
 #include "py_igl/py_writePLY.cpp"
-
+#include "py_igl/py_readPLY.cpp"
 }

+ 12 - 0
python/py_igl/py_readPLY.cpp

@@ -0,0 +1,12 @@
+m.def("readPLY", []
+(
+  const std::string str,
+  Eigen::MatrixXd& V,
+  Eigen::MatrixXi& F,
+  Eigen::MatrixXd& N,
+  Eigen::MatrixXd& UV
+)
+{
+  return igl::readPLY(str,V,F,N,UV);
+}, __doc_igl_readPLY,
+py::arg("str"), py::arg("V"), py::arg("F"), py::arg("N"), py::arg("UV"));

+ 1 - 0
python/python_shared.cpp

@@ -153,6 +153,7 @@ PYBIND11_PLUGIN(pyigl) {
            writeMESH
            writeOBJ
            writePLY
+           readPLY
 
     )pyigldoc");