Browse Source

better compilation/warnings

Former-commit-id: 121e36cd63f924077c3a0cc602ce352952251e59
Alec Jacobson 9 years ago
parent
commit
94b7d07f84
3 changed files with 75 additions and 0 deletions
  1. 56 0
      include/igl/viewer/Viewer.cpp
  2. 18 0
      include/igl/viewer/Viewer.h
  3. 1 0
      shared/cmake/CMakeLists.txt

+ 56 - 0
include/igl/viewer/Viewer.cpp

@@ -6,6 +6,8 @@
 // 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/.
 
+// Must defined this before including Viewer.h
+#define IGL_VIEWER_VIEWER_CPP
 #include "Viewer.h"
 
 #ifdef _WIN32
@@ -273,6 +275,33 @@ namespace viewer
 
   IGL_INLINE Viewer::Viewer()
   {
+    // This mess is to help debug problems arising when compiling
+    // libiglviewer.a with(without) IGL_STATIC_LIBRARY defined and including
+    // Viewer.h without(with) IGL_STATIC_LIBRARY defined.
+#ifdef IGL_STATIC_LIBRARY
+    std::cout<<"igl_with_nanogui_defined_consistently: "<<igl_with_nanogui_defined_consistently()<<std::endl;
+    std::cout<<"igl_with_nanogui_defined_at_compile: "<<  igl_with_nanogui_defined_at_compile()  <<std::endl;
+    std::cout<<"igl_with_nanogui_defined_at_include: "<<  igl_with_nanogui_defined_at_include()  <<std::endl;
+    // First try to first assert
+    assert(igl_with_nanogui_defined_consistently() && 
+      "Must compile and include with IGL_VIEWER_WITH_NANOGUI defined consistently");
+#ifdef NDEBUG
+    // Second print warning since it's hopeless that this will run if wrong.
+    if(!igl_with_nanogui_defined_consistently())
+    {
+      std::cerr<<
+        "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<std::endl<<std::endl<<
+        "WARNING: Seems that IGL_WITH_NANOGUI " <<
+        (igl_with_nanogui_defined_at_compile() ? "was" : "was not") <<
+        " defined"<<std::endl<<"during compilation of Viewer.cpp and "<<
+        (igl_with_nanogui_defined_at_include() ? "was" : "was not") <<
+        " defined"<<std::endl<<"during inclusion of Viewer.h"<<std::endl <<
+        "You're about to get some nasty memory errors."<<std::endl<<std::endl<<
+        "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<std::endl;
+    }
+#endif
+#endif
+
 #ifdef IGL_VIEWER_WITH_NANOGUI
     ngui = nullptr;
     screen = nullptr;
@@ -318,6 +347,10 @@ namespace viewer
   Z       Snap to canonical view
   [,]     Toggle between rotation control types (e.g. trackball, two-axis
           valuator with fixed up)
+#ifdef IGL_VIEWER_WITH_NANOGUI
+  ;       Toggle vertex labels
+  :       Toggle face labels
+#endif
 
 )");
     std::cout<<usage;
@@ -530,6 +563,14 @@ namespace viewer
         }
         return true;
       }
+#ifdef IGL_VIEWER_WITH_NANOGUI
+      case ';':
+        core.show_vertid = !core.show_vertid;
+        return true;
+      case ':':
+        core.show_faceid = !core.show_faceid;
+        return true;
+#endif
       default: break;//do nothing
     }
     return false;
@@ -1003,5 +1044,20 @@ namespace viewer
     launch_shut();
     return EXIT_SUCCESS;
   }
+  IGL_INLINE bool Viewer::igl_with_nanogui_defined_at_compile()
+  {
+#ifdef IGL_VIEWER_WITH_NANOGUI
+    return true;
+#else
+    return false;
+#endif
+  }
+  IGL_INLINE bool Viewer::igl_with_nanogui_defined_consistently()
+  {
+    return 
+      igl_with_nanogui_defined_at_compile() == 
+      igl_with_nanogui_defined_at_include();
+  }
 } // end namespace
 }
+

+ 18 - 0
include/igl/viewer/Viewer.h

@@ -153,10 +153,28 @@ namespace viewer
     void* callback_key_down_data;
     void* callback_key_up_data;
 
+  public:
+
+    static IGL_INLINE bool igl_with_nanogui_defined_at_compile();
+    static IGL_INLINE bool igl_with_nanogui_defined_consistently();
+
   public:
       EIGEN_MAKE_ALIGNED_OPERATOR_NEW
   };
 
+  bool igl_with_nanogui_defined_at_include();
+#ifndef IGL_VIEWER_VIEWER_CPP
+  bool igl_with_nanogui_defined_at_include()
+  {
+    // this must be inlined here.
+#ifdef IGL_VIEWER_WITH_NANOGUI
+    return true;
+#else
+    return false;
+#endif
+  }
+#endif
+
 } // end namespace
 } // end namespace
 

+ 1 - 0
shared/cmake/CMakeLists.txt

@@ -115,6 +115,7 @@ if(LIBIGL_WITH_BBW)
   if(LIBIGL_USE_STATIC_LIBRARY)
     CompileIGL_Module("bbw")
     if(LIBIGL_WITH_MOSEK)
+      find_package(MOSEK REQUIRED)
       list(APPEND LIBIGL_INCLUDE_DIRS ${MOSEK_INCLUDE_DIR})
       target_include_directories(iglbbw PRIVATE ${MOSEK_INCLUDE_DIR})
     else()