Browse Source

merge

Former-commit-id: 2bbb216246b18cfa199f6b38dbe169e5bb2032bf
Alec Jacobson (jalec 12 years ago
parent
commit
ddff8a7887

+ 31 - 1
include/igl/ReAntTweakBar.cpp

@@ -44,7 +44,7 @@ namespace igl
     const char * type_str;
   };
 
-  #define RETW_NUM_DEFAULT_TYPE_STRINGS 23
+  #define RETW_NUM_DEFAULT_TYPE_STRINGS 24
   ReTwTypeString ReTwDefaultTypeStrings[RETW_NUM_DEFAULT_TYPE_STRINGS] = 
   {
     {TW_TYPE_UNDEF,"TW_TYPE_UNDEF"},
@@ -298,6 +298,13 @@ std::string igl::ReTwBar::get_value_as_string(
         sstr << c[0] << " " << c[1] << " " << c[2];
         break;
       }
+    case TW_TYPE_DIR3D:
+      {
+        sstr << "TW_TYPE_DIR3D" << " ";
+        double * d = static_cast<double*>(var);
+        sstr << d[0] << " " << d[1] << " " << d[2];
+        break;
+      }
     case TW_TYPE_DIR3F:
       {
         sstr << "TW_TYPE_DIR3F" << " ";
@@ -508,6 +515,19 @@ bool igl::ReTwBar::set_value_from_string(
         }
         break;
       }
+    //case TW_TYPE_COLOR3D:
+    case TW_TYPE_DIR3D:
+      {
+        if(sscanf(value_str," %lf %lf %lf",&d[0],&d[1],&d[2]) == 3)
+        {
+          value = &d;
+        }else
+        {
+          printf("ERROR: Bad value format...\n");
+          return false;
+        }
+        break;
+      }
     case TW_TYPE_COLOR3F:
     case TW_TYPE_DIR3F:
       {
@@ -631,6 +651,16 @@ bool igl::ReTwBar::set_value_from_string(
             fvar[3] = fvalue[3];
             break;
           }
+        //case TW_TYPE_COLOR3D:
+        case TW_TYPE_DIR3D:
+          {
+            double * dvar = static_cast<double*>(var);
+            double * dvalue = static_cast<double*>(value);
+            dvar[0] = dvalue[0];
+            dvar[1] = dvalue[1];
+            dvar[2] = dvalue[2];
+            break;
+          }
         case TW_TYPE_COLOR3F:
         case TW_TYPE_DIR3F:
           {

+ 4 - 4
include/igl/is_border_vertex.cpp

@@ -3,10 +3,10 @@
 
 #include "tt.h"
 
-template<typename T, typename S>
-IGL_INLINE std::vector<bool> igl::is_border_vertex(const T& V, const Eigen::Matrix<S, Eigen::Dynamic, Eigen::Dynamic>& F)
+template <typename DerivedV, typename DerivedF>
+IGL_INLINE std::vector<bool> igl::is_border_vertex(const Eigen::PlainObjectBase<DerivedV> &V, const Eigen::PlainObjectBase<DerivedF> &F)
 {
-  Eigen::Matrix<S, Eigen::Dynamic, Eigen::Dynamic> FF;
+  Eigen::PlainObjectBase<DerivedF> FF;
   igl::tt(V,F,FF);
   std::vector<bool> ret(V.rows());
   for(unsigned i=0; i<ret.size();++i)
@@ -17,7 +17,7 @@ IGL_INLINE std::vector<bool> igl::is_border_vertex(const T& V, const Eigen::Matr
       if(FF(i,j) == -1)
       {
         ret[F(i,j)]       = true;
-        ret[F(i,(j+1)%3)] = true;
+        ret[F(i,(j+1)%F.cols())] = true;
       }
   return ret;
 }

+ 3 - 3
include/igl/is_border_vertex.h

@@ -12,9 +12,9 @@
 
 namespace igl 
 {
-  template<typename T, typename S>
-  IGL_INLINE std::vector<bool> is_border_vertex(const T& V,
-                                                const Eigen::Matrix<S, Eigen::Dynamic, Eigen::Dynamic>& F);
+  template <typename DerivedV, typename DerivedF>
+  IGL_INLINE std::vector<bool> is_border_vertex(const Eigen::PlainObjectBase<DerivedV> &V,
+                                                const Eigen::PlainObjectBase<DerivedF> &F);
 }
 
 #ifdef IGL_HEADER_ONLY

+ 4 - 4
include/igl/tt.cpp

@@ -9,11 +9,11 @@ IGL_INLINE void igl::tt_preprocess(const Eigen::PlainObjectBase<DerivedV>& /*V*/
                                    std::vector<std::vector<int> >& TTT)
 {
   for(int f=0;f<F.rows();++f)
-    for (int i=0;i<3;++i)
+    for (int i=0;i<F.cols();++i)
     {
       // v1 v2 f ei 
       int v1 = F(f,i);
-      int v2 = F(f,(i+1)%3);
+      int v2 = F(f,(i+1)%F.cols());
       if (v1 > v2) std::swap(v1,v2);
       std::vector<int> r(4);
       r[0] = v1; r[1] = v2;
@@ -29,7 +29,7 @@ IGL_INLINE void igl::tt_extractTT(const Eigen::PlainObjectBase<DerivedF>& F,
                                   std::vector<std::vector<int> >& TTT,
                                   Eigen::PlainObjectBase<DerivedTT>& TT)
 {
-  TT = Eigen::PlainObjectBase<DerivedTT>::Constant((int)(F.rows()),3,-1);
+  TT = Eigen::PlainObjectBase<DerivedTT>::Constant((int)(F.rows()),F.cols(),-1);
   
   for(int i=1;i<(int)TTT.size();++i)
   {
@@ -49,7 +49,7 @@ IGL_INLINE void igl::tt_extractTTi(const Eigen::PlainObjectBase<DerivedF>& F,
                                    std::vector<std::vector<int> >& TTT,
                                    Eigen::PlainObjectBase<DerivedTT>& TTi)
 {
-  TTi = Eigen::PlainObjectBase<DerivedTT>::Constant((int)(F.rows()),3,-1);
+  TTi = Eigen::PlainObjectBase<DerivedTT>::Constant((int)(F.rows()),F.cols(),-1);
   
   for(int i=1;i<(int)TTT.size();++i)
   {