Browse Source

angles --> internal_angles

Former-commit-id: 286edc3c4bf883eef95f82d565b3629208f8ec97
Alec Jacobson 10 years ago
parent
commit
013dd64cde

+ 11 - 0
RELEASE_HISTORY.txt

@@ -14,6 +14,17 @@ Version | Short description
 1.0.1   | Bug fixes and more CGAL support
 1.0.0   | Major beta release: many renames, tutorial, triangle, org. build
 
+## Version 1.2 Changes ##
+This change introduces better organization of dependencies and removes some
+deprecated/repeated functions
+
+### Deprecated/repeated functions ###
+
+Old                              | New
+-------------------------------- | -------------------------------------
+`igl::angles`                    | `igl::internal_angles`
+
+
 ## Version 1.0 Changes ##
 Our beta release marks our confidence that this library can be used outside of
 casual experimenting. To maintain order, we have made a few changes which

+ 1 - 1
examples/intersections/Makefile

@@ -2,7 +2,7 @@
 
 # Shared flags etc.
 include ../Makefile.conf
-LIBIGL_LIB=+liglcgal
+LIBIGL_LIB+=-liglcgal
 
 all: example
 

+ 0 - 51
include/igl/angles.cpp

@@ -1,51 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-//
-// Copyright (C) 2015 Daniele Panozzo <daniele.panozzo@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
-// obtain one at http://mozilla.org/MPL/2.0/.
-#include "angles.h"
-#include <Eigen/Geometry>
-#include <cassert>
-
-template <
-  typename DerivedV,
-  typename DerivedF,
-  typename Derivedtheta>
-void igl::angles(
-  const Eigen::PlainObjectBase<DerivedV>& V,
-  const Eigen::PlainObjectBase<DerivedF>& F,
-  Eigen::PlainObjectBase<Derivedtheta>& theta)
-{
-  theta.resize(F.rows(),F.cols());
-
-  auto corner = [](const Eigen::PlainObjectBase<DerivedV>& x, const Eigen::PlainObjectBase<DerivedV>& y, const Eigen::PlainObjectBase<DerivedV>& z)
-  {
-    Eigen::RowVector3d v1 = (x-y).normalized();
-    Eigen::RowVector3d v2 = (z-y).normalized();
-
-    // http://stackoverflow.com/questions/10133957/signed-angle-between-two-vectors-without-a-reference-plane
-    double s = v1.cross(v2).norm();
-    double c = v1.dot(v2);
-
-    return atan2(s, c);
-  };
-
-  for(unsigned i=0; i<F.rows(); ++i)
-  {
-    for(unsigned j=0; j<F.cols(); ++j)
-    {
-      theta(i,j) = corner(
-        V.row(F(i,int(j-1+F.cols())%F.cols())),
-        V.row(F(i,j)),
-        V.row(F(i,(j+1+F.cols())%F.cols()))
-        );
-    }
-  }
-}
-
-#ifdef IGL_STATIC_LIBRARY
-// Explicit template specialization
-template void igl::angles<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
-#endif

+ 0 - 47
include/igl/angles.h

@@ -1,47 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-//
-// Copyright (C) 2015 Daniele Panozzo <daniele.panozzo@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
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_ANGLES_H
-#define IGL_ANGLES_H
-#ifdef _WIN32
-#  pragma message ( "Deprecated. Use igl/internal_angles.h instead" )
-#else
-#  warning "Deprecated. Use igl/internal_angles.h instead"
-#endif
-
-
-#include "igl_inline.h"
-#include "deprecated.h"
-#include <Eigen/Core>
-namespace igl
-{
-  // ANGLES Compute angles for each corner of each triangle
-  //
-  // Inputs:
-  //   V  #V by dim list of vertex positions
-  //   F  #V by 3[4] list of triangle[quads] indices
-  // Outputs:
-  //   theta  #F by 3[4] list of angles for each corner (in radians)
-  //
-  template <
-  typename DerivedV,
-  typename DerivedF,
-  typename Derivedtheta>
-  IGL_INLINE 
-  IGL_DEPRECATED(
-    void angles(
-    const Eigen::PlainObjectBase<DerivedV>& V,
-    const Eigen::PlainObjectBase<DerivedF>& F,
-    Eigen::PlainObjectBase<Derivedtheta>& theta));
-
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#  include "angles.cpp"
-#endif
-
-#endif

+ 0 - 69
include/igl/get_modifiers.h

@@ -1,69 +0,0 @@
-#ifndef GET_MODIFIERS_H
-#define GET_MODIFIERS_H
-//#include "igl_inline.h"
-namespace igl
-{
-  enum Modifier
-  {
-    MODIFIER_OPTION = 1,
-    MODIFIER_SHIFT = 2,
-    MODIFIER_CONTROL = 4,
-    MODIFIER_COMMAND = 8,
-    NUM_MODIFIERS = 4,
-  };
-  // Retrieve current modifier constellation. 
-  //
-  // Returns int that's an "or" of the active modifiers above.
-  //
-  // FORCED INLINE
-  inline int get_modifiers();
-}
-
-// Implementation 
-
-/* glutGetModifiers return mask. */
-#ifndef GLUT_ACTIVE_SHIFT
-#  define GLUT_ACTIVE_SHIFT 1
-#endif
-#ifndef GLUT_ACTIVE_CTRL
-#  define GLUT_ACTIVE_CTRL 2
-#endif
-#ifndef GLUT_ACTIVE_ALT
-#  define GLUT_ACTIVE_ALT 4
-#endif
-#ifndef GLUT_ACTIVE_COMMAND
-#  define GLUT_ACTIVE_COMMAND 8
-#endif
-
-#ifdef __APPLE__
-//#include <Carbon/HIToolbox/Events.h>
-#include <Carbon/Carbon.h>
-#endif
-
-#warning "igl::get_modifiers is deprecated. If using GLUT, try Alec's glut patch www.alecjacobson.com/weblog/?p=3659 and use glutGetModifiers"
-
-// FORCED INLINE
-inline int igl::get_modifiers()
-{
-  int mod = 0;
-#ifdef __APPLE__
-  // http://stackoverflow.com/a/18082326/148668
-  KeyMap keyStates;
-  const auto & carbon_is_keydown = [&keyStates]( uint16_t vKey )->bool
-  {
-    uint8_t index = vKey / 32 ;
-    uint8_t shift = vKey % 32 ;
-    return keyStates[index].bigEndianValue & (1 << shift) ;
-  };
-  GetKeys(keyStates) ;
-  mod |= (carbon_is_keydown(kVK_Command)?GLUT_ACTIVE_COMMAND:0);
-  mod |= (carbon_is_keydown(kVK_Shift)?GLUT_ACTIVE_SHIFT:0);
-  mod |= (carbon_is_keydown(kVK_Option)?GLUT_ACTIVE_ALT:0);
-  mod |= (carbon_is_keydown(kVK_Control)?GLUT_ACTIVE_CTRL:0);
-#else
-#  warning "igl::get_modifiers not supported on your OS, some demos may not work correctly."
-#endif
-  return mod;
-}
-
-#endif

+ 40 - 9
include/igl/internal_angles.cpp

@@ -1,6 +1,7 @@
 // This file is part of libigl, a simple c++ geometry processing library.
 // 
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// Copyright (C) 2015 Daniele Panozzo <daniele.panozzo@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 
@@ -17,15 +18,45 @@ IGL_INLINE void igl::internal_angles(
 {
   using namespace Eigen;
   using namespace std;
-  // Edge lengths
-  Matrix<
-    typename DerivedV::Scalar,
-    DerivedF::RowsAtCompileTime,
-    DerivedF::ColsAtCompileTime> L;
-  edge_lengths(V,F,L);
+  if(F.cols() == 3)
+  {
+    // Edge lengths
+    Matrix<
+      typename DerivedV::Scalar,
+      DerivedF::RowsAtCompileTime,
+      DerivedF::ColsAtCompileTime> L;
+    edge_lengths(V,F,L);
 
-  assert(F.cols() == 3 && "F should contain triangles");
-  internal_angles(L,K);
+    assert(F.cols() == 3 && "F should contain triangles");
+    internal_angles(L,K);
+  }else
+  {
+    assert(V.cols() == 3 && "If F contains non-triangle facets, V must be 3D");
+    K.resize(F.rows(),F.cols());
+    auto corner = [](
+      const Eigen::PlainObjectBase<DerivedV>& x, 
+      const Eigen::PlainObjectBase<DerivedV>& y, 
+      const Eigen::PlainObjectBase<DerivedV>& z)
+    {
+      Eigen::RowVector3d v1 = (x-y).normalized();
+      Eigen::RowVector3d v2 = (z-y).normalized();
+      // http://stackoverflow.com/questions/10133957/signed-angle-between-two-vectors-without-a-reference-plane
+      double s = v1.cross(v2).norm();
+      double c = v1.dot(v2);
+      return atan2(s, c);
+    };
+    for(unsigned i=0; i<F.rows(); ++i)
+    {
+      for(unsigned j=0; j<F.cols(); ++j)
+      {
+        K(i,j) = corner(
+            V.row(F(i,int(j-1+F.cols())%F.cols())),
+            V.row(F(i,j)),
+            V.row(F(i,(j+1+F.cols())%F.cols()))
+            );
+      }
+    }
+  }
 }
 
 template <typename DerivedL, typename DerivedK>

+ 8 - 4
include/igl/internal_angles.h

@@ -1,6 +1,6 @@
 // This file is part of libigl, a simple c++ geometry processing library.
 // 
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
+// Copyright (C) 2015 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 
@@ -12,12 +12,16 @@
 namespace igl
 {
   // Compute internal angles for a triangle mesh
+  //
   // Inputs:
-  //   V  #V by 3 eigen Matrix of mesh vertex 3D positions
-  //   F  #F by 3 eigen Matrix of face (triangle) indices
+  //   V  #V by dim eigen Matrix of mesh vertex nD positions
+  //   F  #F by poly-size eigen Matrix of face (triangle) indices
   // Output:
-  //   K  #F by 3 eigen Matrix of internal angles
+  //   K  #F by poly-size eigen Matrix of internal angles
   //     for triangles, columns correspond to edges [1,2],[2,0],[0,1]
+  //
+  // Known Issues:
+  //   if poly-size ≠ 3 then dim must equal 3.
   template <typename DerivedV, typename DerivedF, typename DerivedK>
   IGL_INLINE void internal_angles(
     const Eigen::PlainObjectBase<DerivedV>& V,

+ 2 - 2
tutorial/701_Statistics/main.cpp

@@ -5,7 +5,7 @@
 
 #include <igl/is_irregular_vertex.h>
 #include <igl/doublearea.h>
-#include <igl/angles.h>
+#include <igl/internal_angles.h>
 
 int main(int argc, char *argv[])
 {
@@ -40,7 +40,7 @@ int main(int argc, char *argv[])
 
   // Compute per face angles, min, max and standard deviation
   MatrixXd angles;
-  igl::angles(V,F,angles);
+  igl::internal_angles(V,F,angles);
   angles = 360.0 * (angles/(2*M_PI)); // Convert to degrees
 
   double angle_avg   = angles.mean();