Browse Source

fixed many missing IGL_INLINEs

Former-commit-id: 1ccc6e54fe1d57957434eb046ebdc4244f3ae05f
Alec Jacobson 11 years ago
parent
commit
d10afaa873

+ 171 - 174
include/igl/Timer.h

@@ -5,177 +5,174 @@
 // 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/.
-// High Resolution Timer.
-//
-// Resolution on Mac (clock tick)
-// Resolution on Linux (1 us not tested)
-// Resolution on Windows (clock tick not tested)
-
-#ifndef IGL_TIMER_H
-#define IGL_TIMER_H
-
-#ifdef WIN32   // Windows system specific
-#include <windows.h>
-#elif __APPLE__ // Unix based system specific
-#include <mach/mach_time.h> // for mach_absolute_time
-#else
-#include <sys/time.h>
-#endif
-
-namespace igl
-{
-  class Timer
-  {
-  public:
-    // default constructor
-    Timer():
-      stopped(0),
-#ifdef WIN32
-      frequency(),
-      startCount(),
-      endCount()
-#elif __APPLE__
-      startCount(0),
-      endCount(0)
-#else
-      startCount(),
-      endCount()
-#endif
-    {
-#ifdef WIN32
-      QueryPerformanceFrequency(&frequency);
-      startCount.QuadPart = 0;
-      endCount.QuadPart = 0;
-#elif __APPLE__
-      startCount = 0;
-      endCount = 0;
-#else
-      startCount.tv_sec = startCount.tv_usec = 0;
-      endCount.tv_sec = endCount.tv_usec = 0;
-#endif
-      
-      stopped = 0;
-    }
-    // default destructor
-    ~Timer()                     
-    {
-      
-    }
-    
-#ifdef __APPLE__
-    //Raw mach_absolute_times going in, difference in seconds out
-    double subtractTimes( uint64_t endTime, uint64_t startTime )
-    {
-      uint64_t difference = endTime - startTime;
-      static double conversion = 0.0;
-      
-      if( conversion == 0.0 )
-      {
-        mach_timebase_info_data_t info;
-        kern_return_t err = mach_timebase_info( &info );
-        
-        //Convert the timebase into seconds
-        if( err == 0  )
-          conversion = 1e-9 * (double) info.numer / (double) info.denom;
-      }
-      
-      return conversion * (double) difference;
-    }
-#endif
-    
-    // start timer
-    void   start()               
-    {
-      stopped = 0; // reset stop flag
-#ifdef WIN32
-      QueryPerformanceCounter(&startCount);
-#elif __APPLE__
-      startCount = mach_absolute_time();
-#else
-      gettimeofday(&startCount, NULL);
-#endif
-      
-    }
-    
-    // stop the timer
-    void   stop()                
-    {
-      stopped = 1; // set timer stopped flag
-      
-#ifdef WIN32
-      QueryPerformanceCounter(&endCount);
-#elif __APPLE__
-      endCount = mach_absolute_time();
-#else
-      gettimeofday(&endCount, NULL);
-#endif
-      
-    }
-    // get elapsed time in second
-    double getElapsedTime()      
-    {
-      return this->getElapsedTimeInSec();
-    }
-    // get elapsed time in second (same as getElapsedTime)
-    double getElapsedTimeInSec() 
-    {
-      return this->getElapsedTimeInMicroSec() * 0.000001;
-    }
-    
-    // get elapsed time in milli-second
-    double getElapsedTimeInMilliSec()
-    {
-      return this->getElapsedTimeInMicroSec() * 0.001;
-    }
-    // get elapsed time in micro-second
-    double getElapsedTimeInMicroSec()          
-    {
-      double startTimeInMicroSec = 0;
-      double endTimeInMicroSec = 0;
-
-#ifdef WIN32
-      if(!stopped)
-        QueryPerformanceCounter(&endCount);
-      
-      startTimeInMicroSec = 
-        startCount.QuadPart * (1000000.0 / frequency.QuadPart);
-      endTimeInMicroSec = endCount.QuadPart * (1000000.0 / frequency.QuadPart);
-#elif __APPLE__
-      if (!stopped)
-        endCount = mach_absolute_time();
-      
-      return subtractTimes(endCount,startCount)/1e-6;
-#else
-      if(!stopped)
-        gettimeofday(&endCount, NULL);
-      
-      startTimeInMicroSec = 
-        (startCount.tv_sec * 1000000.0) + startCount.tv_usec;
-      endTimeInMicroSec = (endCount.tv_sec * 1000000.0) + endCount.tv_usec;
-#endif
-      
-      return endTimeInMicroSec - startTimeInMicroSec;
-    }
-    
-    
-  protected:
-    
-    
-  private:
-    // stop flag 
-    int    stopped;               
-#ifdef WIN32
-    // ticks per second
-    LARGE_INTEGER frequency;      
-    LARGE_INTEGER startCount;     
-    LARGE_INTEGER endCount;       
-#elif __APPLE__
-    uint64_t startCount;           
-    uint64_t endCount;             
-#else
-    timeval startCount;           
-    timeval endCount;             
-#endif
-  };
-}
-#endif // TIMER_H_DEF
+// High Resolution Timer.
+//
+// Resolution on Mac (clock tick)
+// Resolution on Linux (1 us not tested)
+// Resolution on Windows (clock tick not tested)
+
+#ifndef IGL_TIMER_H
+#define IGL_TIMER_H
+
+#ifdef WIN32   // Windows system specific
+#include <windows.h>
+#elif __APPLE__ // Unix based system specific
+#include <mach/mach_time.h> // for mach_absolute_time
+#else
+#include <sys/time.h>
+#endif
+
+namespace igl
+{
+  class Timer
+  {
+  public:
+    // default constructor
+    Timer():
+      stopped(0),
+#ifdef WIN32
+      frequency(),
+      startCount(),
+      endCount()
+#elif __APPLE__
+      startCount(0),
+      endCount(0)
+#else
+      startCount(),
+      endCount()
+#endif
+    {
+#ifdef WIN32
+      QueryPerformanceFrequency(&frequency);
+      startCount.QuadPart = 0;
+      endCount.QuadPart = 0;
+#elif __APPLE__
+      startCount = 0;
+      endCount = 0;
+#else
+      startCount.tv_sec = startCount.tv_usec = 0;
+      endCount.tv_sec = endCount.tv_usec = 0;
+#endif
+
+      stopped = 0;
+    }
+    // default destructor
+    ~Timer()                     
+    {
+
+    }
+
+#ifdef __APPLE__
+    //Raw mach_absolute_times going in, difference in seconds out
+    double subtractTimes( uint64_t endTime, uint64_t startTime )
+    {
+      uint64_t difference = endTime - startTime;
+      static double conversion = 0.0;
+
+      if( conversion == 0.0 )
+      {
+        mach_timebase_info_data_t info;
+        kern_return_t err = mach_timebase_info( &info );
+
+        //Convert the timebase into seconds
+        if( err == 0  )
+          conversion = 1e-9 * (double) info.numer / (double) info.denom;
+      }
+
+      return conversion * (double) difference;
+    }
+#endif
+
+    // start timer
+    void   start()               
+    {
+      stopped = 0; // reset stop flag
+#ifdef WIN32
+      QueryPerformanceCounter(&startCount);
+#elif __APPLE__
+      startCount = mach_absolute_time();
+#else
+      gettimeofday(&startCount, NULL);
+#endif
+
+    }
+
+    // stop the timer
+    void   stop()                
+    {
+      stopped = 1; // set timer stopped flag
+
+#ifdef WIN32
+      QueryPerformanceCounter(&endCount);
+#elif __APPLE__
+      endCount = mach_absolute_time();
+#else
+      gettimeofday(&endCount, NULL);
+#endif
+
+    }
+    // get elapsed time in second
+    double getElapsedTime()      
+    {
+      return this->getElapsedTimeInSec();
+    }
+    // get elapsed time in second (same as getElapsedTime)
+    double getElapsedTimeInSec() 
+    {
+      return this->getElapsedTimeInMicroSec() * 0.000001;
+    }
+
+    // get elapsed time in milli-second
+    double getElapsedTimeInMilliSec()
+    {
+      return this->getElapsedTimeInMicroSec() * 0.001;
+    }
+    // get elapsed time in micro-second
+    double getElapsedTimeInMicroSec()          
+    {
+      double startTimeInMicroSec = 0;
+      double endTimeInMicroSec = 0;
+
+#ifdef WIN32
+      if(!stopped)
+        QueryPerformanceCounter(&endCount);
+
+      startTimeInMicroSec = 
+        startCount.QuadPart * (1000000.0 / frequency.QuadPart);
+      endTimeInMicroSec = endCount.QuadPart * (1000000.0 / frequency.QuadPart);
+#elif __APPLE__
+      if (!stopped)
+        endCount = mach_absolute_time();
+
+      return subtractTimes(endCount,startCount)/1e-6;
+#else
+      if(!stopped)
+        gettimeofday(&endCount, NULL);
+
+      startTimeInMicroSec = 
+        (startCount.tv_sec * 1000000.0) + startCount.tv_usec;
+      endTimeInMicroSec = (endCount.tv_sec * 1000000.0) + endCount.tv_usec;
+#endif
+
+      return endTimeInMicroSec - startTimeInMicroSec;
+    }
+
+  private:
+    // stop flag 
+    int    stopped;               
+#ifdef WIN32
+    // ticks per second
+    LARGE_INTEGER frequency;      
+    LARGE_INTEGER startCount;     
+    LARGE_INTEGER endCount;       
+#elif __APPLE__
+    uint64_t startCount;           
+    uint64_t endCount;             
+#else
+    timeval startCount;           
+    timeval endCount;             
+#endif
+  };
+}
+#endif // TIMER_H_DEF
+

+ 1 - 1
include/igl/angular_distance.cpp

@@ -8,7 +8,7 @@
 #include "angular_distance.h"
 #include <igl/EPS.h>
 #include <igl/PI.h>
-double igl::angular_distance(
+IGL_INLINE double igl::angular_distance(
   const Eigen::Quaterniond & A,
   const Eigen::Quaterniond & B)
 {

+ 1 - 1
include/igl/angular_distance.h

@@ -18,7 +18,7 @@ namespace igl
   //   A  unit quaternion
   //   B  unit quaternion
   // Returns angular distance
-  double angular_distance(
+  IGL_INLINE double angular_distance(
     const Eigen::Quaterniond & A,
     const Eigen::Quaterniond & B);
 }

+ 1 - 1
include/igl/arap_rhs.h

@@ -27,7 +27,7 @@ namespace igl
   //     b = K * reshape(permute(R,[3 1 2]),size(V|F,1)*size(V,2)*size(V,2),1);
   //   
   // See also: arap_linear_block
-  void arap_rhs(
+  IGL_INLINE void arap_rhs(
     const Eigen::MatrixXd & V, 
     const Eigen::MatrixXi & F,
     const igl::ARAPEnergyType energy,

+ 2 - 2
include/igl/dated_copy.cpp

@@ -9,7 +9,7 @@
 #include <unistd.h>
 #include <iostream>
 
-bool igl::dated_copy(const std::string & src_path, const std::string & dir)
+IGL_INLINE bool igl::dated_copy(const std::string & src_path, const std::string & dir)
 {
   using namespace std;
   using namespace igl;
@@ -75,7 +75,7 @@ bool igl::dated_copy(const std::string & src_path, const std::string & dir)
   return true;
 }
 
-bool igl::dated_copy(const std::string & src_path)
+IGL_INLINE bool igl::dated_copy(const std::string & src_path)
 {
   return dated_copy(src_path,dirname(src_path));
 }

+ 2 - 2
include/igl/dated_copy.h

@@ -20,9 +20,9 @@ namespace igl
   // Example:
   //   dated_copy("/path/to/foo","/bar/");
   //   // copies /path/to/foo to /bar/foo-2013-12-12T18-10-56
-  bool dated_copy(const std::string & src_path, const std::string & dir);
+  IGL_INLINE bool dated_copy(const std::string & src_path, const std::string & dir);
   // Wrapper using directory of source file
-  bool dated_copy(const std::string & src_path);
+  IGL_INLINE bool dated_copy(const std::string & src_path);
 }
 #ifdef IGL_HEADER_ONLY
 #  include "dated_copy.cpp"

+ 1 - 1
include/igl/draw_rectangular_marquee.cpp

@@ -9,7 +9,7 @@
 #include "OpenGL_convenience.h"
 #include "material_colors.h"
 
-void igl::draw_rectangular_marquee(
+IGL_INLINE void igl::draw_rectangular_marquee(
   const int from_x,
   const int from_y,
   const int to_x,

+ 2 - 1
include/igl/draw_rectangular_marquee.h

@@ -7,6 +7,7 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #ifndef IGL_DRAW_RECTANGULAR_MARQUEE_H
 #define IGL_DRAW_RECTANGULAR_MARQUEE_H
+#include "igl_inline.h"
 namespace igl
 {
   // Draw a rectangular marquee (selection box) in screen space. This sets up
@@ -17,7 +18,7 @@ namespace igl
   //   from_y  y coordinate of from point
   //   to_x  x coordinate of to point
   //   to_y  y coordinate of to point
-  void draw_rectangular_marquee(
+  IGL_INLINE void draw_rectangular_marquee(
     const int from_x,
     const int from_y,
     const int to_x,

+ 1 - 1
include/igl/flare_textures.h.REMOVED.git-id

@@ -1 +1 @@
-da428b7e4052aa0f654f311c46b07a27bc50d653
+d92e8438dc4ccf21c1064a9ccd2b87fa58e99862

+ 2 - 2
include/igl/hsv_to_rgb.cpp

@@ -10,7 +10,7 @@
 
 
 template <typename T>
-void igl::hsv_to_rgb(const T * hsv, T * rgb)
+IGL_INLINE void igl::hsv_to_rgb(const T * hsv, T * rgb)
 {
   igl::hsv_to_rgb( 
       hsv[0],hsv[1],hsv[2],
@@ -18,7 +18,7 @@ void igl::hsv_to_rgb(const T * hsv, T * rgb)
 }
 
 template <typename T>
-void igl::hsv_to_rgb( 
+IGL_INLINE void igl::hsv_to_rgb( 
   const T & h, const T & s, const T & v, 
   T & r, T & g, T & b)
 {

+ 2 - 2
include/igl/hsv_to_rgb.h

@@ -21,9 +21,9 @@ namespace igl
   //   g  green value ([0,1])
   //   b  blue value ([0,1])
   template <typename T>
-  void hsv_to_rgb(const T * hsv, T * rgb);
+  IGL_INLINE void hsv_to_rgb(const T * hsv, T * rgb);
   template <typename T>
-  void hsv_to_rgb( 
+  IGL_INLINE void hsv_to_rgb( 
     const T & h, const T & s, const T & v, 
     T & r, T & g, T & b);
 };

+ 2 - 2
include/igl/jet.cpp

@@ -54,13 +54,13 @@
 
 
 template <typename T>
-void igl::jet(const T x, T * rgb)
+IGL_INLINE void igl::jet(const T x, T * rgb)
 {
   igl::jet(x,rgb[0],rgb[1],rgb[2]);
 }
 
 template <typename T>
-void igl::jet(const T x, T & r, T & g, T & b)
+IGL_INLINE void igl::jet(const T x, T & r, T & g, T & b)
 {
   // Only important if the number of colors is small. In which case the rest is
   // still wrong anyway

+ 2 - 2
include/igl/jet.h

@@ -33,9 +33,9 @@ namespace igl
   //   g  green value
   //   b  blue value
   template <typename T>
-  void jet(const T f, T * rgb);
+  IGL_INLINE void jet(const T f, T * rgb);
   template <typename T>
-  void jet(const T f, T & r, T & g, T & b);
+  IGL_INLINE void jet(const T f, T & r, T & g, T & b);
 };
 
 #ifdef IGL_HEADER_ONLY

+ 19 - 18
include/igl/lens_flare.cpp

@@ -18,25 +18,26 @@
 
 // http://www.opengl.org/archives/resources/features/KilgardTechniques/LensFlare/glflare.c
 
-static void setup_texture(
-  const uint8_t * texture, 
-  const int width,
-  const int height,
-  GLuint texobj,
-  GLenum minFilter, GLenum maxFilter)
-{
-  glBindTexture(GL_TEXTURE_2D, texobj);
-  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter);
-  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, maxFilter);
-  glTexImage2D(GL_TEXTURE_2D, 0, 1, width, height, 0,
-    GL_LUMINANCE, GL_UNSIGNED_BYTE, texture);
-}
-
-void igl::lens_flare_load_textures(
+IGL_INLINE void igl::lens_flare_load_textures(
   std::vector<GLuint> & shine_id,
   std::vector<GLuint> & flare_id)
 {
+
+  const auto setup_texture =[](
+    const uint8_t * texture, 
+    const int width,
+    const int height,
+    GLuint texobj,
+    GLenum minFilter, GLenum maxFilter)
+  {
+    glBindTexture(GL_TEXTURE_2D, texobj);
+    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter);
+    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, maxFilter);
+    glTexImage2D(GL_TEXTURE_2D, 0, 1, width, height, 0,
+      GL_LUMINANCE, GL_UNSIGNED_BYTE, texture);
+  };
+
   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
   shine_id.resize(10);
   glGenTextures(10,&shine_id[0]);
@@ -58,7 +59,7 @@ void igl::lens_flare_load_textures(
   }
 }
 
-void igl::lens_flare_create(
+IGL_INLINE void igl::lens_flare_create(
   const float * A,
   const float * B,
   const float * C,
@@ -84,7 +85,7 @@ void igl::lens_flare_create(
   flares[11] = Flare(5, -1.0f, 0.03f, A, 0.2);
 }
 
-void igl::lens_flare_draw(
+IGL_INLINE void igl::lens_flare_draw(
   const std::vector<igl::Flare> & flares,
   const std::vector<GLuint> & shine_ids,
   const std::vector<GLuint> & flare_ids,

+ 4 - 3
include/igl/lens_flare.h

@@ -11,6 +11,7 @@
 #ifndef IGL_NO_OPENGL
 #include <igl/OpenGL_convenience.h>
 #include <Eigen/Core>
+#include "igl_inline.h"
 
 #include <vector>
 
@@ -45,7 +46,7 @@ namespace igl
   // Outputs:
   //   shine  list of texture ids for shines
   //   flare  list of texture ids for flares
-  void lens_flare_load_textures(
+  IGL_INLINE void lens_flare_load_textures(
     std::vector<GLuint> & shine_ids,
     std::vector<GLuint> & flare_ids);
   
@@ -57,7 +58,7 @@ namespace igl
   //   C  secondary color
   // Outputs:
   //   flares  list of flare objects
-  void lens_flare_create(
+  IGL_INLINE void lens_flare_create(
     const float * A,
     const float * B,
     const float * C,
@@ -74,7 +75,7 @@ namespace igl
   //   shine_tic  current "tic" in shine textures
   // Outputs:
   //   shine_tic  current "tic" in shine textures
-  void lens_flare_draw(
+  IGL_INLINE void lens_flare_draw(
     const std::vector<Flare> & flares,
     const std::vector<GLuint> & shine_ids,
     const std::vector<GLuint> & flare_ids,

+ 1 - 1
include/igl/path_to_executable.cpp

@@ -2,7 +2,7 @@
 #ifdef __APPLE__
 #  include <mach-o/dyld.h>
 #endif
-std::string igl::path_to_executable()
+IGL_INLINE std::string igl::path_to_executable()
 {
   // http://pastebin.com/ffzzxPzi
   using namespace std;

+ 1 - 1
include/igl/path_to_executable.h

@@ -13,7 +13,7 @@ namespace igl
 {
   // Return the path of the current executable.
   // Note: Tested for Mac OS X
-  std::string path_to_executable();
+  IGL_INLINE std::string path_to_executable();
 }
 #ifdef IGL_HEADER_ONLY
 #  include "path_to_executable.cpp"

+ 2 - 2
include/igl/random_dir.cpp

@@ -9,7 +9,7 @@
 #include <igl/PI.h>
 #include <cmath>
 
-Eigen::Vector3d igl::random_dir()
+IGL_INLINE Eigen::Vector3d igl::random_dir()
 {
   using namespace Eigen;
   using namespace igl;
@@ -22,7 +22,7 @@ Eigen::Vector3d igl::random_dir()
   return Vector3d(x,y,z); 
 }
 
-Eigen::MatrixXd igl::random_dir_stratified(const int n)
+IGL_INLINE Eigen::MatrixXd igl::random_dir_stratified(const int n)
 {
   using namespace Eigen;
   using namespace igl;

+ 2 - 2
include/igl/random_dir.h

@@ -14,14 +14,14 @@
 namespace igl
 {
   // Generate a uniformly random unit direction in 3D, return as vector
-  Eigen::Vector3d random_dir();
+  IGL_INLINE Eigen::Vector3d random_dir();
   // Generate n stratified uniformly random unit directions in 3d, return as rows
   // of an n by 3 matrix
   //
   // Inputs:
   //   n  number of directions
   // Return n by 3 matrix of random directions
-  Eigen::MatrixXd random_dir_stratified(const int n);
+  IGL_INLINE Eigen::MatrixXd random_dir_stratified(const int n);
 }
 
 #ifdef IGL_HEADER_ONLY

+ 1 - 1
include/igl/rgb_to_hsv.cpp

@@ -8,7 +8,7 @@
 #include "rgb_to_hsv.h"
 
 template <typename R,typename H>
-void igl::rgb_to_hsv(const R * rgb, H * hsv)
+IGL_INLINE void igl::rgb_to_hsv(const R * rgb, H * hsv)
 {
   // http://en.literateprograms.org/RGB_to_HSV_color_space_conversion_%28C%29
   R rgb_max = 0.0;

+ 1 - 1
include/igl/rgb_to_hsv.h

@@ -21,7 +21,7 @@ namespace igl
   //   s  saturation value ([0,1])
   //   v  value value ([0,1])
   template <typename R,typename H>
-  void rgb_to_hsv(const R * rgb, H * hsv);
+  IGL_INLINE void rgb_to_hsv(const R * rgb, H * hsv);
 };
 
 #ifdef IGL_HEADER_ONLY

+ 1 - 1
include/igl/sample_edges.h

@@ -24,7 +24,7 @@ namespace igl
   // Output:
   //   S  sampled vertices, size less than # edges * (2+k) by dim always begins
   //        with V so that E is also defined over S
-  void sample_edges(
+  IGL_INLINE void sample_edges(
     const Eigen::MatrixXd & V,
     const Eigen::MatrixXi & E,
     const int k,

+ 1 - 1
style.css

@@ -188,7 +188,7 @@ ul
 {
   margin:0px;
   padding: 0px 20px;
-  list-style-type:none;
+  /*list-style-type:none;*/
 }
 li { font-size: 100% }
 li li { font-size: 90% }