Эх сурвалжийг харах

remove duplicated readOBJPoly and match ordering of readOBJ eigen version with vector

Former-commit-id: 1c252f0452a0d68ee451ea493e28b925754ec831
Alec Jacobson 10 жил өмнө
parent
commit
dcd8c80fbc

+ 0 - 76
include/igl/readOBJ.cpp

@@ -286,70 +286,6 @@ IGL_INLINE bool igl::readOBJ(
       return false;
       return false;
     }
     }
   }
   }
-  // Legacy
-  if(F.cols() != 3)
-  {
-    fprintf(stderr,
-            "Error: readOBJ(filename,V,F) is meant for reading triangle-only"
-            " meshes. This mesh has faces all with size %d. See readOBJ.h for other"
-            " options.\n",
-            (int)F.cols());
-    return false;
-  }
-  return true;
-}
-
-template <typename DerivedV, typename DerivedF, typename DerivedT, typename Index>
-IGL_INLINE bool igl::readOBJPoly(
-  const std::string str,
-  Eigen::PlainObjectBase<DerivedV>& V,
-  std::vector<std::vector< Index > >& F,
-  Eigen::PlainObjectBase<DerivedV>& CN,
-  Eigen::PlainObjectBase<DerivedF>& FN,
-  Eigen::PlainObjectBase<DerivedT>& TC,
-  Eigen::PlainObjectBase<DerivedF>& FTC)
-{
-  std::vector<std::vector<double> > vV,vTC,vN;
-  std::vector<std::vector<Index> > vF,vFTC,vFN;
-  bool success = igl::readOBJ(str,vV,vTC,vN,vF,vFTC,vFN);
-  if(!success)
-    return false;
-
-  bool V_rect = igl::list_to_matrix(vV,V);
-  if(!V_rect)
-    return false;
-
-  F = vF;
-
-  if(!vN.empty())
-  {
-    bool VN_rect = igl::list_to_matrix(vN,CN);
-    if(!VN_rect)
-      return false;
-  }
-
-  if(!vFN.empty())
-  {
-    bool FN_rect = igl::list_to_matrix(vFN,FN);
-    if(!FN_rect)
-      return false;
-  }
-
-  if(!vTC.empty())
-  {
-
-    bool T_rect = igl::list_to_matrix(vTC,TC);
-    if(!T_rect)
-      return false;
-  }
-  if(!vFTC.empty())
-  {
-
-    bool FTC_rect = igl::list_to_matrix(vFTC,FTC);
-    if(!FTC_rect)
-      return false;
-  }
-
   return true;
   return true;
 }
 }
 
 
@@ -380,17 +316,6 @@ IGL_INLINE bool igl::readOBJ(
     // igl::list_to_matrix(vF,F) already printed error message to std err
     // igl::list_to_matrix(vF,F) already printed error message to std err
     return false;
     return false;
   }
   }
-  // THIS IS ANNOYING, I WANT TO READ QUADS, Why not?
-  //// Legacy
-  //if(F.cols() != 3)
-  //{
-  //  fprintf(stderr,
-  //          "Error: readOBJ(filename,V,F) is meant for reading triangle-only"
-  //          " meshes. This mesh has faces all with size %d. See readOBJ.h for other"
-  //          " options.\n",
-  //          (int)F.cols());
-  //  return false;
-  //}
   return true;
   return true;
 }
 }
 
 
@@ -401,5 +326,4 @@ template bool igl::readOBJ<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matr
 template bool igl::readOBJ<Eigen::Matrix<double, -1, 3, 1, -1, 3>, Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1>, Eigen::Matrix<double, -1, 2, 1, -1, 2> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 2, 1, -1, 2> >&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> >&);
 template bool igl::readOBJ<Eigen::Matrix<double, -1, 3, 1, -1, 3>, Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1>, Eigen::Matrix<double, -1, 2, 1, -1, 2> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 2, 1, -1, 2> >&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> >&);
 template bool igl::readOBJ<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 template bool igl::readOBJ<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 template bool igl::readOBJ<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(std::string, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
 template bool igl::readOBJ<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(std::string, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
-template bool igl::readOBJPoly<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, int>(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 #endif
 #endif

+ 8 - 63
include/igl/readOBJ.h

@@ -33,10 +33,10 @@ namespace igl
   //  str  path to .obj file
   //  str  path to .obj file
   // Outputs:
   // Outputs:
   //   V  double matrix of vertex positions  #V by 3
   //   V  double matrix of vertex positions  #V by 3
-  //   F  #F list of face indices into vertex positions
   //   TC  double matrix of texture coordinats #TC by 2
   //   TC  double matrix of texture coordinats #TC by 2
-  //   FTC  #F list of face indices into vertex texture coordinates
   //   N  double matrix of corner normals #N by 3
   //   N  double matrix of corner normals #N by 3
+  //   F  #F list of face indices into vertex positions
+  //   FTC  #F list of face indices into vertex texture coordinates
   //   FN  #F list of face indices into vertex normals
   //   FN  #F list of face indices into vertex normals
   // Returns true on success, false on errors
   // Returns true on success, false on errors
   template <typename Scalar, typename Index>
   template <typename Scalar, typename Index>
@@ -54,74 +54,19 @@ namespace igl
     const std::string obj_file_name, 
     const std::string obj_file_name, 
     std::vector<std::vector<Scalar > > & V,
     std::vector<std::vector<Scalar > > & V,
     std::vector<std::vector<Index > > & F);
     std::vector<std::vector<Index > > & F);
-
 #ifndef IGL_NO_EIGEN
 #ifndef IGL_NO_EIGEN
-  //! Read a mesh from an ascii obj file
-  // Inputs:
-  //   str  path to .obj file
-  // Outputs:
-  //   V  eigen matrix #V by 3
-  //   F  eigen matrix #F by 3
-  //
-  // KNOWN BUG: This only knows how to read *triangle* meshes. It will probably
-  // crash or give garbage on anything else.
-  //
-  // KNOWN BUG: This only knows how to face lines without normal or texture
-  // indices. It will probably crash or give garbage on anything else.
-  //
-  // KNOWN BUG: The order of the attributes is different than the vector
-  // version above
+  // Eigen Wrappers. These will return true only if the data is perfectly
+  // "rectangular": All faces are the same degree, all have the same number of
+  // textures/normals etc.
   template <typename DerivedV, typename DerivedF, typename DerivedT>
   template <typename DerivedV, typename DerivedF, typename DerivedT>
   IGL_INLINE bool readOBJ(
   IGL_INLINE bool readOBJ(
     const std::string str,
     const std::string str,
     Eigen::PlainObjectBase<DerivedV>& V,
     Eigen::PlainObjectBase<DerivedV>& V,
-    Eigen::PlainObjectBase<DerivedF>& F,
-    Eigen::PlainObjectBase<DerivedV>& CN,
-    Eigen::PlainObjectBase<DerivedF>& FN,
     Eigen::PlainObjectBase<DerivedT>& TC,
     Eigen::PlainObjectBase<DerivedT>& TC,
-    Eigen::PlainObjectBase<DerivedF>& FTC);
-
-  //! Read a poly mesh from an ascii obj file
-  // Inputs:
-  //   str  path to .obj file
-  // Outputs:
-  //   V  eigen matrix #V by 3
-  //   POLYF vector of vector with face indices
-  //
-  //
-  // KNOWN BUG: This only knows how to face lines without normal or texture
-  // indices. It will probably crash or give garbage on anything else.
-  //
-  // KNOWN BUG: The order of the attributes is different than the vector
-  // version above
-  template <
-    typename DerivedV, 
-    typename DerivedF, 
-    typename DerivedT, 
-    typename Index>
-  IGL_INLINE 
-  IGL_DEPRECATED(
-  bool readOBJPoly(
-    const std::string str,
-    Eigen::PlainObjectBase<DerivedV>& V,
-    std::vector<std::vector<Index> >& F,
     Eigen::PlainObjectBase<DerivedV>& CN,
     Eigen::PlainObjectBase<DerivedV>& CN,
-    Eigen::PlainObjectBase<DerivedF>& FN,
-    Eigen::PlainObjectBase<DerivedT>& TC,
-    Eigen::PlainObjectBase<DerivedF>& FTC));
-  
-  //! Read a mesh from an ascii obj file
-  // Inputs:
-  //   str  path to .obj file
-  // Outputs:
-  //   V  eigen matrix #V by 3
-  //   F  eigen matrix #F by 3
-  //
-  // KNOWN BUG: This only knows how to read *triangle* meshes. It will probably
-  // crash or give garbage on anything else.
-  //
-  // KNOWN BUG: This only knows how to face lines without normal or texture
-  // indices. It will probably crash or give garbage on anything else.
+    Eigen::PlainObjectBase<DerivedF>& F,
+    Eigen::PlainObjectBase<DerivedF>& FTC,
+    Eigen::PlainObjectBase<DerivedF>& FN);
   template <typename DerivedV, typename DerivedF>
   template <typename DerivedV, typename DerivedF>
   IGL_INLINE bool readOBJ(
   IGL_INLINE bool readOBJ(
     const std::string str,
     const std::string str,