Browse Source

missing isolines_map

Alec Jacobson 6 years ago
parent
commit
b95646d268
2 changed files with 93 additions and 0 deletions
  1. 52 0
      include/igl/isolines_map.cpp
  2. 41 0
      include/igl/isolines_map.h

+ 52 - 0
include/igl/isolines_map.cpp

@@ -0,0 +1,52 @@
+#include "isolines_map.h"
+#include <iostream>
+
+template <
+  typename DerivedCM,
+  typename Derivediso_color,
+  typename DerivedICM
+  >
+IGL_INLINE void igl::isolines_map(
+  const Eigen::MatrixBase<DerivedCM> & CM, 
+  const Eigen::MatrixBase<Derivediso_color> & iso_color,
+  const int interval_thickness,
+  const int iso_thickness,
+  Eigen::PlainObjectBase<DerivedICM> & ICM)
+{
+  ICM.resize(CM.rows()*interval_thickness+(CM.rows()-1)*iso_thickness,3);
+  {
+    int k = 0;
+    for(int c = 0;c<CM.rows();c++)
+    {
+      for(int i = 0;i<interval_thickness;i++)
+      {
+        ICM.row(k++) = CM.row(c);
+      }
+      if(c+1 != CM.rows())
+      {
+        for(int i = 0;i<iso_thickness;i++)
+        {
+          ICM.row(k++) = iso_color;
+        }
+      }
+    }
+    assert(k == ICM.rows());
+  }
+}
+
+template <
+  typename DerivedCM,
+  typename DerivedICM
+  >
+IGL_INLINE void igl::isolines_map(
+  const Eigen::MatrixBase<DerivedCM> & CM, 
+  Eigen::PlainObjectBase<DerivedICM> & ICM)
+{
+  return isolines_map(
+    CM, Eigen::Matrix<typename DerivedCM::Scalar,1,3>(0,0,0), 10, 1, ICM);
+}
+
+#ifdef IGL_STATIC_LIBRARY
+// Explicit template instantiation
+template void igl::isolines_map<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
+#endif

+ 41 - 0
include/igl/isolines_map.h

@@ -0,0 +1,41 @@
+#ifndef IGL_ISOLINES_MAP_H
+#define IGL_ISOLINES_MAP_H
+#include "igl_inline.h"
+#include <Eigen/Core>
+
+namespace igl
+{
+  // Inject a given colormap with evenly spaced isolines.
+  //
+  // Inputs:
+  //   CM  #CM by 3 list of colors
+  //   ico_color  1 by 3 isoline color
+  //   interval_thickness  number of times to repeat intervals (original colors)
+  //   iso_thickness  number of times to repeat isoline color (in between
+  //     intervals)
+  // Outputs:
+  //   ICM  #CM*interval_thickness + (#CM-1)*iso_thickness by 3 list of outputs
+  //     colors
+  template <
+    typename DerivedCM,
+    typename Derivediso_color,
+    typename DerivedICM >
+  IGL_INLINE void isolines_map(
+    const Eigen::MatrixBase<DerivedCM> & CM, 
+    const Eigen::MatrixBase<Derivediso_color> & iso_color,
+    const int interval_thickness,
+    const int iso_thickness,
+    Eigen::PlainObjectBase<DerivedICM> & ICM);
+  template <
+    typename DerivedCM,
+    typename DerivedICM>
+  IGL_INLINE void isolines_map(
+    const Eigen::MatrixBase<DerivedCM> & CM, 
+    Eigen::PlainObjectBase<DerivedICM> & ICM);
+}
+
+#ifndef IGL_STATIC_LIBRARY
+#  include "isolines_map.cpp"
+#endif
+
+#endif