Browse Source

templates

Former-commit-id: 5ebb0e08a32a845623df723b3eaadf7166ceeda9
Alec Jacobson 8 năm trước cách đây
mục cha
commit
30fabdc2cb
2 tập tin đã thay đổi với 26 bổ sung0 xóa
  1. 20 0
      include/igl/matlab_format.cpp
  2. 6 0
      include/igl/matlab_format.h

+ 20 - 0
include/igl/matlab_format.cpp

@@ -91,6 +91,26 @@ IGL_INLINE Eigen::IOFormat igl::matlab_format()
     "\n];");
 }
 
+IGL_INLINE const std::string igl::matlab_format(
+ const double v,
+ const std::string name)
+{
+  using namespace std;
+  string prefix = "";
+  if(!name.empty())
+  {
+    prefix = name + " = ";
+  }
+  return STR(prefix<<v<<";");
+}
+
+IGL_INLINE const std::string igl::matlab_format(
+    const float v,
+    const std::string name)
+{
+  return matlab_format(double(v),name);
+}
+
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template instantiation
 // generated by autoexplicit.sh

+ 6 - 0
include/igl/matlab_format.h

@@ -62,6 +62,12 @@ namespace igl
   IGL_INLINE const std::string matlab_format(
     const Eigen::SparseMatrix<DerivedS> & S,
     const std::string name = "");
+  IGL_INLINE const std::string matlab_format(
+    const double v,
+    const std::string name = "");
+  IGL_INLINE const std::string matlab_format(
+    const float v,
+    const std::string name = "");
   // Return just IOFormat 
   //
   // Example: