Browse Source

Make use of IGL_DEPRECATED (#1380)

* Make use of IGL_DEPRECATED() macro in igl::all_edges, igl::internal_angles and igl::is_border_vertex.
CTRL+F for "deprecated" find functions where the comment says that the functioin is deprecated.

* Removed #include deprecated.h for igl::nchoosek and igl::readOBJ because it looks like the functions which have been marked as deprecated are already gone.

* update IGL_DEPRECATED to make use of C++14 feature [[deprecated]].

* replace deprecated igl:is_border_vertex(V,F) with igl::is_border_vertex(F).

* fixed IGL_DEPRECATED: added prama message if the compiler is unknonw and fixed macro for MSVC.

* Add IGL_DEPRECATED to igl::remove_duplicates() to mark it as deprecated.
Nico 6 years ago
parent
commit
5d9d9c8eff

+ 2 - 1
include/igl/all_edges.h

@@ -8,6 +8,7 @@
 #ifndef IGL_ALL_EDGES_H
 #ifndef IGL_ALL_EDGES_H
 #define IGL_ALL_EDGES_H
 #define IGL_ALL_EDGES_H
 #include "igl_inline.h"
 #include "igl_inline.h"
+#include "deprecated.h"
 #include <Eigen/Dense>
 #include <Eigen/Dense>
 namespace igl
 namespace igl
 {
 {
@@ -26,7 +27,7 @@ namespace igl
   // show up once for each direction and non-manifold edges may appear more than
   // show up once for each direction and non-manifold edges may appear more than
   // once for each direction).
   // once for each direction).
   template <typename DerivedF, typename DerivedE>
   template <typename DerivedF, typename DerivedE>
-  IGL_INLINE void all_edges(
+  IGL_DEPRECATED IGL_INLINE void all_edges(
     const Eigen::MatrixBase<DerivedF> & F,
     const Eigen::MatrixBase<DerivedF> & F,
     Eigen::PlainObjectBase<DerivedE> & E);
     Eigen::PlainObjectBase<DerivedE> & E);
 }
 }

+ 1 - 1
include/igl/boundary_loop.cpp

@@ -29,7 +29,7 @@ IGL_INLINE void igl::boundary_loop(
   triangle_triangle_adjacency(F,TT,TTi);
   triangle_triangle_adjacency(F,TT,TTi);
   vertex_triangle_adjacency(Vdummy,F,VF,VFi);
   vertex_triangle_adjacency(Vdummy,F,VF,VFi);
 
 
-  vector<bool> unvisited = is_border_vertex(Vdummy,F);
+  vector<bool> unvisited = is_border_vertex(F);
   set<int> unseen;
   set<int> unseen;
   for (size_t i = 0; i < unvisited.size(); ++i)
   for (size_t i = 0; i < unvisited.size(); ++i)
   {
   {

+ 1 - 1
include/igl/cross_field_mismatch.cpp

@@ -79,7 +79,7 @@ public:
   PD2(_PD2)
   PD2(_PD2)
   {
   {
     igl::per_face_normals(V,F,N);
     igl::per_face_normals(V,F,N);
-    V_border = igl::is_border_vertex(V,F);
+    V_border = igl::is_border_vertex(F);
     igl::vertex_triangle_adjacency(V,F,VF,VFi);
     igl::vertex_triangle_adjacency(V,F,VF,VFi);
     igl::triangle_triangle_adjacency(F,TT,TTi);
     igl::triangle_triangle_adjacency(F,TT,TTi);
   }
   }

+ 34 - 11
include/igl/deprecated.h

@@ -8,21 +8,44 @@
 #ifndef IGL_DEPRECATED_H
 #ifndef IGL_DEPRECATED_H
 #define IGL_DEPRECATED_H
 #define IGL_DEPRECATED_H
 // Macro for marking a function as deprecated.
 // Macro for marking a function as deprecated.
-// 
-// http://stackoverflow.com/a/295229/148668
-#if defined(__GNUC__) || defined(__clang__)
-#define IGL_DEPRECATED(func) func __attribute__ ((deprecated))
-#elif defined(_MSC_VER)
-#define IGL_DEPRECATED(func) __declspec(deprecated) func
+// Use C++14 feature [[deprecated]] if available.
+// See also https://stackoverflow.com/questions/295120/c-mark-as-deprecated/21265197#21265197
+
+#ifdef __has_cpp_attribute
+#  define IGL_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
+#else
+#  define IGL_HAS_CPP_ATTRIBUTE(x) 0
+#endif
+
+#ifdef _MSC_VER
+#  define IGL_MSC_VER _MSC_VER
 #else
 #else
-#pragma message("WARNING: You need to implement IGL_DEPRECATED for this compiler")
-#define IGL_DEPRECATED(func) func
+#  define IGL_MSC_VER 0
+#endif
+
+#ifndef IGL_DEPRECATED
+#  if (IGL_HAS_CPP_ATTRIBUTE(deprecated) && __cplusplus >= 201402L) || \
+      IGL_MSC_VER >= 1900
+#    define IGL_DEPRECATED [[deprecated]]
+#  else
+#    if defined(__GNUC__) || defined(__clang__)
+#      define IGL_DEPRECATED __attribute__((deprecated))
+#    elif IGL_MSC_VER
+#      define IGL_DEPRECATED __declspec(deprecated)
+#    else
+#      pragma message("WARNING: You need to implement IGL_DEPRECATED for this compiler")
+#      define IGL_DEPRECATED /* deprecated */
+#    endif
+#  endif
 #endif
 #endif
+
 // Usage:
 // Usage:
 //
 //
-//     template <typename T> IGL_INLINE void my_func(Arg1 a);
+//     template <typename T>
+//     IGL_INLINE void my_func(Arg1 a);
 //
 //
-// becomes 
+// becomes
 //
 //
-//     template <typename T> IGL_INLINE IGL_DEPRECATED(void my_func(Arg1 a));
+//     template <typename T>
+//     IGL_DEPRECATED IGL_INLINE void my_func(Arg1 a);
 #endif
 #endif

+ 1 - 1
include/igl/find_cross_field_singularities.cpp

@@ -22,7 +22,7 @@ IGL_INLINE void igl::find_cross_field_singularities(const Eigen::MatrixBase<Deri
                                                     Eigen::PlainObjectBase<DerivedO> &isSingularity,
                                                     Eigen::PlainObjectBase<DerivedO> &isSingularity,
                                                     Eigen::PlainObjectBase<DerivedO> &singularityIndex)
                                                     Eigen::PlainObjectBase<DerivedO> &singularityIndex)
 {
 {
-  std::vector<bool> V_border = igl::is_border_vertex(V,F);
+  std::vector<bool> V_border = igl::is_border_vertex(F);
 
 
   std::vector<std::vector<int> > VF;
   std::vector<std::vector<int> > VF;
   std::vector<std::vector<int> > VFi;
   std::vector<std::vector<int> > VFi;

+ 4 - 2
include/igl/internal_angles.h

@@ -8,6 +8,7 @@
 #ifndef IGL_INTERNAL_ANGLES_H
 #ifndef IGL_INTERNAL_ANGLES_H
 #define IGL_INTERNAL_ANGLES_H
 #define IGL_INTERNAL_ANGLES_H
 #include "igl_inline.h"
 #include "igl_inline.h"
+#include "deprecated.h"
 #include <Eigen/Core>
 #include <Eigen/Core>
 namespace igl
 namespace igl
 {
 {
@@ -49,9 +50,10 @@ namespace igl
   //   Usage of internal_angles_using_squared_edge_lengths is preferred to internal_angles_using_squared_edge_lengths
   //   Usage of internal_angles_using_squared_edge_lengths is preferred to internal_angles_using_squared_edge_lengths
   //   This function is deprecated and probably will be removed in future versions
   //   This function is deprecated and probably will be removed in future versions
   template <typename DerivedL, typename DerivedK>
   template <typename DerivedL, typename DerivedK>
-  IGL_INLINE void internal_angles_using_edge_lengths(
+  IGL_DEPRECATED IGL_INLINE void internal_angles_using_edge_lengths(
     const Eigen::MatrixBase<DerivedL>& L,
     const Eigen::MatrixBase<DerivedL>& L,
-    Eigen::PlainObjectBase<DerivedK> & K);}
+    Eigen::PlainObjectBase<DerivedK> & K);
+}
 
 
 #ifndef IGL_STATIC_LIBRARY
 #ifndef IGL_STATIC_LIBRARY
 #  include "internal_angles.cpp"
 #  include "internal_angles.cpp"

+ 2 - 2
include/igl/is_border_vertex.h

@@ -8,7 +8,7 @@
 #ifndef IGL_IS_BORDER_VERTEX_H
 #ifndef IGL_IS_BORDER_VERTEX_H
 #define IGL_IS_BORDER_VERTEX_H
 #define IGL_IS_BORDER_VERTEX_H
 #include "igl_inline.h"
 #include "igl_inline.h"
-
+#include "deprecated.h"
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include <vector>
 #include <vector>
 
 
@@ -29,7 +29,7 @@ namespace igl
    const Eigen::MatrixBase<DerivedF> &F);
    const Eigen::MatrixBase<DerivedF> &F);
   // Deprecated:
   // Deprecated:
   template <typename DerivedV, typename DerivedF>
   template <typename DerivedV, typename DerivedF>
-  IGL_INLINE std::vector<bool> is_border_vertex(
+  IGL_DEPRECATED IGL_INLINE std::vector<bool> is_border_vertex(
    const Eigen::MatrixBase<DerivedV> &V,
    const Eigen::MatrixBase<DerivedV> &V,
    const Eigen::MatrixBase<DerivedF> &F);
    const Eigen::MatrixBase<DerivedF> &F);
 }
 }

+ 1 - 1
include/igl/is_irregular_vertex.cpp

@@ -27,7 +27,7 @@ IGL_INLINE std::vector<bool> igl::is_irregular_vertex(const Eigen::MatrixBase<De
     }
     }
   }
   }
 
 
-  std::vector<bool> border = is_border_vertex(V,F);
+  std::vector<bool> border = is_border_vertex(F);
 
 
   std::vector<bool> res(count.size());
   std::vector<bool> res(count.size());
 
 

+ 1 - 1
include/igl/line_field_mismatch.cpp

@@ -92,7 +92,7 @@ public:
         PD2(_PD2)
         PD2(_PD2)
     {
     {
         igl::per_face_normals(V,F,N);
         igl::per_face_normals(V,F,N);
-        V_border = igl::is_border_vertex(V,F);
+        V_border = igl::is_border_vertex(F);
         igl::vertex_triangle_adjacency(V,F,VF,VFi);
         igl::vertex_triangle_adjacency(V,F,VF,VFi);
         igl::triangle_triangle_adjacency(F,TT,TTi);
         igl::triangle_triangle_adjacency(F,TT,TTi);
     }
     }

+ 0 - 1
include/igl/nchoosek.h

@@ -9,7 +9,6 @@
 #ifndef IGL_NCHOOSEK
 #ifndef IGL_NCHOOSEK
 #define IGL_NCHOOSEK
 #define IGL_NCHOOSEK
 #include "igl_inline.h"
 #include "igl_inline.h"
-#include "deprecated.h"
 #include <vector>
 #include <vector>
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>

+ 0 - 1
include/igl/readOBJ.h

@@ -8,7 +8,6 @@
 #ifndef IGL_READOBJ_H
 #ifndef IGL_READOBJ_H
 #define IGL_READOBJ_H
 #define IGL_READOBJ_H
 #include "igl_inline.h"
 #include "igl_inline.h"
-#include "deprecated.h"
 // History:
 // History:
 //  return type changed from void to bool  Alec 18 Sept 2011
 //  return type changed from void to bool  Alec 18 Sept 2011
 //  added pure vector of vectors version that has much more support Alec 31 Oct
 //  added pure vector of vectors version that has much more support Alec 31 Oct

+ 2 - 1
include/igl/remove_duplicates.h

@@ -8,6 +8,7 @@
 #ifndef IGL_REMOVE_DUPLICATES_H
 #ifndef IGL_REMOVE_DUPLICATES_H
 #define IGL_REMOVE_DUPLICATES_H
 #define IGL_REMOVE_DUPLICATES_H
 #include "igl_inline.h"
 #include "igl_inline.h"
+#include "deprecated.h"
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 namespace igl 
 namespace igl 
@@ -32,7 +33,7 @@ namespace igl
 //                                   const double epsilon = 2.2204e-15);
 //                                   const double epsilon = 2.2204e-15);
   
   
   template <typename DerivedV, typename DerivedF>
   template <typename DerivedV, typename DerivedF>
-  IGL_INLINE void remove_duplicates(
+  IGL_DEPRECATED IGL_INLINE void remove_duplicates(
     const Eigen::MatrixBase<DerivedV> &V,
     const Eigen::MatrixBase<DerivedV> &V,
     const Eigen::MatrixBase<DerivedF> &F,
     const Eigen::MatrixBase<DerivedF> &F,
     Eigen::PlainObjectBase<DerivedV> &NV,
     Eigen::PlainObjectBase<DerivedV> &NV,