Преглед на файлове

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

Conflicts:
	include/igl/matlab_format.cpp

Former-commit-id: 495053cc9b731d3f3eea82ba4d14ba2ee688671e
Olga Diamanti преди 10 години
родител
ревизия
50345c6914

+ 1 - 1
include/igl/comiso/miq.cpp.REMOVED.git-id

@@ -1 +1 @@
-afbb44c112debcdd5d73337d16f4014d2d1ba373
+b90def20af8d5ae79dd59841a4b4a4de7b2b6fe5

+ 15 - 13
include/igl/embree/unproject_in_mesh.cpp

@@ -52,16 +52,17 @@ IGL_INLINE int igl::unproject_in_mesh(
     case 0:
       break;
     case 1:
-    {
-      obj = (s + dir*hits[0].t).cast<typename Derivedobj::Scalar>();
-      break;
-    }
-    case 2:
     default:
-    {
-      obj = 0.5*((s + dir*hits[0].t) + (s + dir*hits[1].t)).cast<typename Derivedobj::Scalar>();
+  {
+      obj = (s + dir*hits[0].t).cast<typename Derivedobj::Scalar>();
       break;
     }
+    // case 2:
+    // default:
+    // {
+    //   obj = 0.5*((s + dir*hits[0].t) + (s + dir*hits[1].t)).cast<typename Derivedobj::Scalar>();
+    //   break;
+    // }
   }
   return hits.size();
 }
@@ -98,16 +99,17 @@ IGL_INLINE int igl::unproject_in_mesh(
     case 0:
       break;
     case 1:
-    {
-      obj = (s + dir*hits[0].t).cast<typename Derivedobj::Scalar>();
-      break;
-    }
-    case 2:
     default:
     {
-      obj = 0.5*((s + dir*hits[0].t) + (s + dir*hits[1].t)).cast<typename Derivedobj::Scalar>();
+      obj = (s + dir*hits[0].t).cast<typename Derivedobj::Scalar>();
       break;
     }
+    // case 2:
+    // default:
+    // {
+    //   obj = 0.5*((s + dir*hits[0].t) + (s + dir*hits[1].t)).cast<typename Derivedobj::Scalar>();
+    //   break;
+    // }
   }
   return hits.size();
 }

+ 3 - 2
include/igl/matlab_format.cpp

@@ -120,9 +120,10 @@ template Eigen::WithFormat<Eigen::Matrix<float, 2, 2, 1, 2, 2> > const igl::matl
 template Eigen::WithFormat<Eigen::Matrix<float, -1, -1, 0, -1, -1> > const igl::matlab_format<Eigen::Matrix<float, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >);
 template Eigen::WithFormat<Eigen::Matrix<double, 3, 3, 1, 3, 3> > const igl::matlab_format<Eigen::Matrix<double, 3, 3, 1, 3, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 3, 1, 3, 3> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >);
 template Eigen::WithFormat<Eigen::Array<double, -1, 1, 0, -1, 1> > const igl::matlab_format<Eigen::Array<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Array<double, -1, 1, 0, -1, 1> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >);
-template Eigen::WithFormat<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const igl::matlab_format<Eigen::Matrix<double, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >);
-template Eigen::WithFormat<Eigen::Matrix<double, 1, 2, 1, 1, 2> > const igl::matlab_format<Eigen::Matrix<double, 1, 2, 1, 1, 2> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 2, 1, 1, 2> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >);
 template Eigen::WithFormat<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const igl::matlab_format<Eigen::Matrix<double, 1, 3, 1, 1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >);
+template Eigen::WithFormat<Eigen::Matrix<double, 1, 2, 1, 1, 2> > const igl::matlab_format<Eigen::Matrix<double, 1, 2, 1, 1, 2> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 2, 1, 1, 2> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >);
 template Eigen::WithFormat<Eigen::Matrix<int, -1, 2, 0, -1, 2> > const igl::matlab_format<Eigen::Matrix<int, -1, 2, 0, -1, 2> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >);
 template Eigen::WithFormat<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const igl::matlab_format<Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >);
+template Eigen::WithFormat<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const igl::matlab_format<Eigen::Matrix<double, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >);
+
 #endif

+ 5 - 0
include/igl/n_polyvector.cpp

@@ -495,6 +495,11 @@ IGL_INLINE void igl::n_polyvector(const Eigen::MatrixXd &V,
     isConstrained(b(i)) = 1;
     cfW.row(b(i)) << bc.row(i);
   }
+  if (b.size() == F.rows())
+  {
+    output = cfW;
+    return;
+  }
 
   int n = cfW.cols()/3;
   igl::PolyVectorFieldFinder<Eigen::MatrixXd, Eigen::MatrixXi> pvff(V,F,n);

+ 9 - 4
include/igl/png/render_to_png.cpp

@@ -1,9 +1,9 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2013 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 
+//
+// 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 "render_to_png.h"
 #include <YImage.hpp>
@@ -49,3 +49,8 @@ IGL_INLINE bool igl::render_to_png(
   delete img;
   return ret;
 }
+
+#ifdef IGL_STATIC_LIBRARY
+// Explicit template specialization
+// template bool igl::render_to_png(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int, int, bool, bool);
+#endif;

+ 29 - 8
include/igl/viewer/Viewer.cpp

@@ -77,15 +77,19 @@ static double scroll_x = 0;
 static double scroll_y = 0;
 
 namespace {
-void TW_CALL copy_str(std::string& dst, const std::string& src)
+  #ifndef NO_TBAR
+  void TW_CALL copy_str(std::string& dst, const std::string& src)
 {
   dst = src;
 }
+#endif
 }
 
 static void glfw_mouse_press(GLFWwindow* window, int button, int action, int modifier)
 {
+  #ifndef NO_TBAR
   bool tw_used = TwEventMouseButtonGLFW(button, action);
+  #endif
   igl::Viewer::MouseButton mb;
 
   if (button == GLFW_MOUSE_BUTTON_1)
@@ -97,10 +101,12 @@ static void glfw_mouse_press(GLFWwindow* window, int button, int action, int mod
 
   if (action == GLFW_PRESS)
   {
+    #ifndef NO_TBAR
     if(!tw_used)
     {
       __viewer->mouse_down(mb,modifier);
     }
+    #endif
   } else
   {
     // Always call mouse_up on up
@@ -115,6 +121,7 @@ static void glfw_error_callback(int error, const char* description)
 }
 
 int global_KMod = 0;
+#ifndef NO_TBAR
 
 int TwEventKeyGLFW3(int glfwKey, int glfwAction)
 {
@@ -257,19 +264,21 @@ int TwEventKeyGLFW3(int glfwKey, int glfwAction)
 
   return handled;
 }
-
+#endif
 static void glfw_key_callback(GLFWwindow* window, int key, int scancode, int action, int modifier)
 {
   if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
     glfwSetWindowShouldClose(window, GL_TRUE);
 
-  if (!TwEventKeyGLFW3(key,action))
+    #ifndef NO_TBAR
+    if (!TwEventKeyGLFW3(key,action))
   {
     if (action == GLFW_PRESS)
       __viewer->key_down(key, modifier);
     else
       __viewer->key_up(key, modifier);
   }
+  #endif
 }
 
 static void glfw_window_size(GLFWwindow* window, int width, int height)
@@ -279,6 +288,7 @@ static void glfw_window_size(GLFWwindow* window, int width, int height)
 
   __viewer->resize(w, h);
 
+#ifndef NO_TBAR
   TwWindowSize(w, h);
   const auto & bar = __viewer->bar;
   // Keep AntTweakBar on right side of screen and height == opengl height
@@ -294,15 +304,18 @@ static void glfw_window_size(GLFWwindow* window, int width, int height)
   size[1] = highdpi*(height-pos[1]-10);
   TwSetParam(bar, NULL, "position", TW_PARAM_INT32, 2, pos);
   TwSetParam(bar, NULL, "size", TW_PARAM_INT32, 2,size);
+#endif
 }
 
 static void glfw_mouse_move(GLFWwindow* window, double x, double y)
 {
+  #ifndef NO_TBAR
   if(!TwEventMousePosGLFW(x*highdpi,y*highdpi) || __viewer->down)
   {
     // Call if TwBar hasn't used or if down
     __viewer->mouse_move(x*highdpi, y*highdpi);
   }
+  #endif
 }
 
 static void glfw_mouse_scroll(GLFWwindow* window, double x, double y)
@@ -311,20 +324,25 @@ static void glfw_mouse_scroll(GLFWwindow* window, double x, double y)
   scroll_x += x;
   scroll_y += y;
 
+  #ifndef NO_TBAR
   if (!TwEventMouseWheelGLFW(scroll_y))
     __viewer->mouse_scroll(y);
+    #endif
 }
 
 static void glfw_char_callback(GLFWwindow* window, unsigned int c)
 {
+  #ifndef NO_TBAR
   if ((c & 0xff00)==0)
     TwKeyPressed(c, global_KMod);
+    #endif
 }
 
 namespace igl
 {
   void Viewer::init()
   {
+    #ifndef NO_TBAR
     // Create a tweak bar
     bar = TwNewBar("libIGL-Viewer");
     TwDefine(" libIGL-Viewer help='This is a simple 3D mesh viewer.' "); // Message added to the help bar->
@@ -408,7 +426,7 @@ namespace igl
                " group='Overlays'"
                " label='Show Faces Labels' key='CTRL+;' help='Toggle face"
                " indices'");
-
+#endif
     core.init();
 
     if (callback_init)
@@ -791,7 +809,9 @@ namespace igl
       if (plugins[i]->post_draw())
         break;
 
-    TwDraw();
+        #ifndef NO_TBAR
+        TwDraw();
+        #endif
   }
 
   bool Viewer::save_scene()
@@ -840,7 +860,7 @@ namespace igl
   {
     core.viewport = Eigen::Vector4f(0,0,w,h);
   }
-
+  #ifndef NO_TBAR
   void TW_CALL Viewer::snap_to_canonical_quaternion_cb(void *clientData)
   {
     Eigen::Vector4f snapq = static_cast<Viewer *>(clientData)->core.trackball_angle;
@@ -895,7 +915,7 @@ namespace igl
 
     static_cast<Viewer *>(clientData)->load_mesh_from_file(fname.c_str());
   }
-
+#endif
   int Viewer::launch(std::string filename)
   {
     GLFWwindow* window;
@@ -944,9 +964,10 @@ namespace igl
     glfwSetInputMode(window,GLFW_CURSOR,GLFW_CURSOR_NORMAL);
 
     // Initialize AntTweakBar
+    #ifndef NO_TBAR
     TwInit(TW_OPENGL_CORE, NULL);
     TwCopyStdStringToClientFunc(static_cast<TwCopyStdStringToClient>(::copy_str));
-
+#endif
 
     // Initialize IGL viewer
     init();

+ 9 - 2
include/igl/viewer/Viewer.h

@@ -12,7 +12,10 @@
 #define IGL_OPENGL_4
 #endif
 
+// #define NO_TBAR
+#ifndef NO_TBAR
 #include <AntTweakBar.h>
+#endif
 
 #include <vector>
 #include <string>
@@ -71,17 +74,19 @@ namespace igl
     bool down;
     bool hack_never_moved;
 
+    #ifndef NO_TBAR
     // Anttweak bar
     TwBar* bar;
-
+    #endif
     // Keep track of the global position of the scrollwheel
     float scroll_position;
 
     // UI Enumerations
     enum MouseButton {IGL_LEFT, IGL_MIDDLE, IGL_RIGHT};
     enum MouseMode { NOTHING, ROTATION, ZOOM, PAN, TRANSLATE} mouse_mode;
+    #ifndef NO_TBAR
     enum KeyModifier { NO_KEY = TW_KMOD_NONE, SHIFT = TW_KMOD_SHIFT, CTRL =TW_KMOD_CTRL, ALT = TW_KMOD_ALT } key_modifier;
-
+#endif
     Viewer();
     ~Viewer();
 
@@ -133,6 +138,7 @@ namespace igl
     void* callback_key_up_data;
 
 
+    #ifndef NO_TBAR
     /********* AntTweakBar callbacks *********/
     static void TW_CALL snap_to_canonical_quaternion_cb(void *clientData);
     static void TW_CALL save_scene_cb(void *clientData);
@@ -143,6 +149,7 @@ namespace igl
     static void TW_CALL get_face_based_cb(void *param, void *clientData);
     static void TW_CALL set_invert_normals_cb(const void *param, void *clientData);
     static void TW_CALL get_invert_normals_cb(void *param, void *clientData);
+    #endif
   public:
       EIGEN_MAKE_ALIGNED_OPERATOR_NEW
   };

+ 1 - 1
include/igl/viewer/ViewerCore.cpp

@@ -400,7 +400,7 @@ IGL_INLINE igl::ViewerCore::ViewerCore()
   show_texture = false;
 
   // Default point size / line width
-  point_size = 15;
+  point_size = 30;
   line_width = 0.5f;
   is_animating = false;
   animation_max_fps = 30.;

+ 1 - 0
include/igl/writePLY.cpp

@@ -9,6 +9,7 @@
 #include <vector>
 
 #include <igl/ply.h>
+#include <vector>
 
 template <
   typename DerivedV,