Quellcode durchsuchen

Merge branch 'master' of https://github.com/libigl/libigl

Former-commit-id: aa9b4b6a78e488a1287339ddc524ab4309b9a337
schuellc vor 9 Jahren
Ursprung
Commit
97b144255a

+ 2 - 3
include/igl/decimate.cpp

@@ -18,8 +18,9 @@ IGL_INLINE bool igl::decimate(
   Eigen::MatrixXd & U,
   Eigen::MatrixXi & G)
 {
+  int m = F.rows();
   const auto & max_m_faces = 
-    [&max_m,&F](
+    [&max_m,&m](
     const Eigen::MatrixXd &,
     const Eigen::MatrixXi &,
     const Eigen::MatrixXi &,
@@ -35,8 +36,6 @@ IGL_INLINE bool igl::decimate(
     const int,
     const int)->bool
     {
-      using namespace std;
-      static int m = F.rows();
       m-=2;
       return m<=(int)max_m;
     };

+ 16 - 0
include/igl/matlab/requires_arg.cpp

@@ -0,0 +1,16 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#include "requires_arg.h"
+#include "../C_STR.h"
+#include "mexErrMsgTxt.h"
+
+IGL_INLINE void igl::matlab::requires_arg(const int i, const int nrhs, const char *name)
+{
+  mexErrMsgTxt((i+1)<nrhs,
+      C_STR("Parameter '"<<name<<"' requires argument"));
+}

+ 29 - 0
include/igl/matlab/requires_arg.h

@@ -0,0 +1,29 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_REQUIRES_ARG_H
+#define IGL_REQUIRES_ARG_H
+#include "../igl_inline.h"
+#include <mex.h>
+namespace igl
+{
+  namespace matlab
+  {
+    // Simply throw an error if (i+1)<rhs 
+    //
+    // Input:
+    //   i  index of current arg
+    //   nrhs  total number of args
+    //   name of current arg
+    IGL_INLINE void requires_arg(const int i, const int nrhs, const char *name);
+  }
+}
+#ifndef IGL_STATIC_LIBRARY
+#  include "requires_arg.cpp"
+#endif
+#endif
+

+ 41 - 0
include/igl/matlab/validate_arg.cpp

@@ -0,0 +1,41 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#include "validate_arg.h"
+#include "requires_arg.h"
+
+IGL_INLINE void igl::matlab::validate_arg_scalar(
+    const int i, const int nrhs, const mxArray * prhs[], const char * name)
+{
+  requires_arg(i,nrhs,name);
+  mexErrMsgTxt(mxGetN(prhs[i+1])==1 && mxGetM(prhs[i+1])==1,
+      C_STR("Parameter '"<<name<<"' requires scalar argument"));
+}
+
+IGL_INLINE void igl::matlab::validate_arg_logical(
+    const int i, const int nrhs, const mxArray * prhs[], const char * name)
+{
+  requires_arg(i,nrhs,name);
+  mexErrMsgTxt(mxIsLogical(prhs[i+1]),
+    C_STR("Parameter '"<<name<<"' requires Logical argument"));
+}
+
+IGL_INLINE void igl::matlab::validate_arg_char(
+    const int i, const int nrhs, const mxArray * prhs[], const char * name)
+{
+  requires_arg(i,nrhs,name);
+  mexErrMsgTxt(mxIsChar(prhs[i+1]),
+    C_STR("Parameter '"<<name<<"' requires char argument"));
+}
+
+IGL_INLINE void igl::matlab::validate_arg_double(
+    const int i, const int nrhs, const mxArray * prhs[], const char * name)
+{
+  requires_arg(i,nrhs,name);
+  mexErrMsgTxt(mxIsDouble(prhs[i+1]),
+    C_STR("Parameter '"<<name<<"' requires double argument"));
+}

+ 36 - 0
include/igl/matlab/validate_arg.h

@@ -0,0 +1,36 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_VALIDATE_ARG_H
+#define IGL_VALIDATE_ARG_H
+#include "../igl_inline.h"
+#include <mex.h>
+namespace igl
+{
+  namespace matlab
+  {
+    // Throw an error if arg i+1 is not a scalar
+    //
+    // Inputs:
+    //   i  index of current arguement
+    //   nrhs  total number of arguments
+    //   prhs  pointer to arguements array
+    //   name   name of current argument
+    IGL_INLINE void validate_arg_scalar(
+      const int i, const int nrhs, const mxArray * prhs[], const char * name);
+    IGL_INLINE void validate_arg_logical(
+      const int i, const int nrhs, const mxArray * prhs[], const char * name);
+    IGL_INLINE void validate_arg_char(
+      const int i, const int nrhs, const mxArray * prhs[], const char * name);
+    IGL_INLINE void validate_arg_double(
+      const int i, const int nrhs, const mxArray * prhs[], const char * name);
+  }
+}
+#ifndef IGL_STATIC_LIBRARY
+#  include "validate_arg.cpp"
+#endif
+#endif

+ 3 - 0
include/igl/png/texture_from_png.h

@@ -40,6 +40,9 @@ namespace igl
     // Output:
     //  R,G,B,A texture channels
     // Returns true on success, false on failure
+    //
+    // Todo: this is an inappropriate function name. This is really just
+    // reading a png.... Not necessarily as a texture.
     IGL_INLINE bool texture_from_png(const std::string png_file,
     Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& R,
     Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& G,