Browse Source

Merge

Former-commit-id: 52e2fc7c0a4c07adf9b7bbbba5ed5ec8f64c3f25
Daniele Panozzo 11 years ago
parent
commit
28aebb722a

+ 0 - 1
examples/principal_curvature/curvature.REMOVED.git-id

@@ -1 +0,0 @@
-22b42436be2b065746a3a3d1c9bd95b10940a1f3

+ 17 - 7
include/igl/ReAntTweakBar.cpp

@@ -19,6 +19,7 @@ IGL_INLINE TwType igl::ReTwDefineEnum(
   const TwEnumVal *enumValues, 
   unsigned int nbValues)
 {
+  using namespace std;
   // copy enum valus into vector
   std::vector<TwEnumVal> enum_vals;
   enum_vals.resize(nbValues);
@@ -30,6 +31,7 @@ IGL_INLINE TwType igl::ReTwDefineEnum(
 
   ReTw_custom_types[type] = 
     std::pair<const char *,std::vector<TwEnumVal> >(name,enum_vals);
+
   return type;
 }
 
@@ -64,10 +66,17 @@ IGL_INLINE TwType igl::ReTwDefineEnum(
     for( int i=0; i<(int)Labels.size(); i++ )
     {
         Vals[i].Value = i;
-        Vals[i].Label = Labels[i].c_str();
+        // Wrong:
+        //Vals[i].Label = Labels[i].c_str();
+        // Allocate char on heap
+        // http://stackoverflow.com/a/10050258/148668
+        char * c_label = new char[Labels[i].length()+1];
+        std::strcpy(c_label, Labels[i].c_str());
+        Vals[i].Label = c_label;
     }
 
-    return ReTwDefineEnum(_Name, Vals.empty() ? NULL : &(Vals[0]), (unsigned int)Vals.size());
+    const TwType type = ReTwDefineEnum(_Name, Vals.empty() ? NULL : &(Vals[0]), (unsigned int)Vals.size());
+    return type;
   }
 }
 
@@ -416,14 +425,15 @@ IGL_INLINE std::string igl::ReTwBar::get_value_as_string(
       }
     default:
       {
-        std::map<TwType,std::pair<const char *,std::vector<TwEnumVal> > >::iterator iter = 
+        using namespace std;
+        std::map<TwType,std::pair<const char *,std::vector<TwEnumVal> > >::const_iterator iter = 
           ReTw_custom_types.find(type);
         if(iter != ReTw_custom_types.end())
         {
           sstr << (*iter).second.first << " ";
           int enum_val = *(static_cast<int*>(var));
           // try find display name for enum value
-          std::vector<TwEnumVal>::iterator eit = (*iter).second.second.begin();
+          std::vector<TwEnumVal>::const_iterator eit = (*iter).second.second.begin();
           bool found = false;
           for(;eit<(*iter).second.second.end();eit++)
           {
@@ -523,7 +533,7 @@ IGL_INLINE bool igl::ReTwBar::type_from_string(const char *type_str, TwType & ty
   }
 
   // then check custom types
-  std::map<TwType,std::pair<const char *,std::vector<TwEnumVal> > >::iterator iter = 
+  std::map<TwType,std::pair<const char *,std::vector<TwEnumVal> > >::const_iterator iter = 
     ReTw_custom_types.begin();
   for(;iter != ReTw_custom_types.end(); iter++)
   {
@@ -680,11 +690,11 @@ bool igl::ReTwBar::set_value_from_string(
       }
     default:
       // Try to find type in custom enum types
-      std::map<TwType,std::pair<const char *,std::vector<TwEnumVal> > >::iterator iter = 
+      std::map<TwType,std::pair<const char *,std::vector<TwEnumVal> > >::const_iterator iter = 
         ReTw_custom_types.find(type);
       if(iter != ReTw_custom_types.end())
       {
-        std::vector<TwEnumVal>::iterator eit = (*iter).second.second.begin();
+        std::vector<TwEnumVal>::const_iterator eit = (*iter).second.second.begin();
         bool found = false;
         for(;eit<(*iter).second.second.end();eit++)
         {

+ 1 - 3
include/igl/boundary_conditions.h

@@ -3,8 +3,6 @@
 #include "igl_inline.h"
 #include <Eigen/Dense>
 
-// Note: the elements field is currently unused but is left her for consistency
-// with the matlab version (where it is also unused). 10/25/2012
 namespace igl
 {
 
@@ -15,7 +13,7 @@ namespace igl
   //   C  #C by dim list of handle positions
   //   P  #P by 1 list of point handle indices into C
   //   BE  #BE by 2 list of bone edge indices into C
-  //   CE  #CE by 2 list of cage edge indices into *P*, unused
+  //   CE  #CE by 2 list of cage edge indices into *P*
   // Outputs:
   //   b  #b list of boundary indices (indices into V of vertices which have
   //     known, fixed values)