Explorar el Código

clean up principal curvature example

Former-commit-id: 15a0c8f54997e299f4f85aecaa156f706a763d33
Alec Jacobson hace 11 años
padre
commit
450d22530b

+ 2 - 0
include/igl/adjacency_list.cpp

@@ -160,5 +160,7 @@ IGL_INLINE void igl::adjacency_list(
 
 #ifndef IGL_HEADER_ONLY
 // Explicit template specialization
+// generated by autoexplicit.sh
+template void igl::adjacency_list<Eigen::Matrix<int, -1, -1, 0, -1, -1>, int>(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, bool);
 template void igl::adjacency_list<Eigen::Matrix<int, -1, 3, 0, -1, 3>, int>(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, bool);
 #endif

+ 2 - 0
include/igl/avg_edge_length.cpp

@@ -32,4 +32,6 @@ double igl::avg_edge_length(
 #ifndef IGL_HEADER_ONLY
 // Explicit template specialization
 // generated by autoexplicit.sh
+template double igl::avg_edge_length<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -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&);
+// generated by autoexplicit.sh
 #endif

+ 3 - 0
include/igl/jet.cpp

@@ -116,6 +116,9 @@ IGL_INLINE void igl::jet(
 }
 
 #ifndef IGL_NO_HEADER
+// Explicit template specialization
+// generated by autoexplicit.sh
+template void igl::jet<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
 template void igl::jet<double>(double, double*);
 template void igl::jet<double>(double, double&, double&, double&);
 template void igl::jet<float>(float, float*);

+ 21 - 10
include/igl/principal_curvature.cpp

@@ -772,17 +772,22 @@ IGL_INLINE void CurvatureCalculator::printCurvature(std::string outpath)
 
 }
 
-template <typename DerivedV, typename DerivedF>
+template <
+  typename DerivedV, 
+  typename DerivedF,
+  typename DerivedPD1, 
+  typename DerivedPD2, 
+  typename DerivedPV1, 
+  typename DerivedPV2>
 IGL_INLINE void igl::principal_curvature(
-                                         const Eigen::PlainObjectBase<DerivedV>& V,
-                                         const Eigen::PlainObjectBase<DerivedF>& F,
-                                         Eigen::PlainObjectBase<DerivedV>& PD1,
-                                         Eigen::PlainObjectBase<DerivedV>& PD2,
-                                         Eigen::PlainObjectBase<DerivedV>& PV1,
-                                         Eigen::PlainObjectBase<DerivedV>& PV2,
-                                         unsigned radius,
-                                         bool useKring
-                                         )
+  const Eigen::PlainObjectBase<DerivedV>& V,
+  const Eigen::PlainObjectBase<DerivedF>& F,
+  Eigen::PlainObjectBase<DerivedPD1>& PD1,
+  Eigen::PlainObjectBase<DerivedPD2>& PD2,
+  Eigen::PlainObjectBase<DerivedPV1>& PV1,
+  Eigen::PlainObjectBase<DerivedPV2>& PV2,
+  unsigned radius,
+  bool useKring)
 {
   using namespace std;
 
@@ -836,3 +841,9 @@ IGL_INLINE void igl::principal_curvature(
   }
 
 }
+
+#ifndef IGL_HEADER_ONLY
+// Explicit template specialization
+// generated by autoexplicit.sh
+template void igl::principal_curvature<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::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -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> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, unsigned int, bool);
+#endif

+ 11 - 5
include/igl/principal_curvature.h

@@ -46,14 +46,20 @@ namespace igl
   // Daniele Panozzo, Enrico Puppo, Luigi Rocca
   // GraVisMa, 2010
 
-template <typename DerivedV, typename DerivedF>
+template <
+  typename DerivedV, 
+  typename DerivedF,
+  typename DerivedPD1, 
+  typename DerivedPD2, 
+  typename DerivedPV1, 
+  typename DerivedPV2>
 IGL_INLINE void principal_curvature(
   const Eigen::PlainObjectBase<DerivedV>& V,
   const Eigen::PlainObjectBase<DerivedF>& F,
-  Eigen::PlainObjectBase<DerivedV>& PD1,
-  Eigen::PlainObjectBase<DerivedV>& PD2,
-  Eigen::PlainObjectBase<DerivedV>& PV1,
-  Eigen::PlainObjectBase<DerivedV>& PV2,
+  Eigen::PlainObjectBase<DerivedPD1>& PD1,
+  Eigen::PlainObjectBase<DerivedPD2>& PD2,
+  Eigen::PlainObjectBase<DerivedPV1>& PV1,
+  Eigen::PlainObjectBase<DerivedPV2>& PV2,
   unsigned radius = 5,
   bool useKring = true);
 }

+ 1 - 1
scripts/autoexplicit.sh

@@ -15,7 +15,7 @@ while read line; do
   #echo "symbol = $symbol"
   filename=`echo "$symbol" | perl -pe "s#.*?igl::([A-z0-9_]*).*$'$'#\1#"`
   #echo "filename = $filename"
-  cpp="$filename.cpp"
+  cpp="$LIBIGL/include/igl/$filename.cpp"
   # append .cpp and check that file exists
   if [ ! -e "$cpp" ]
   then

+ 19 - 9
tutorial/203_CurvatureDirections/main.cpp

@@ -6,32 +6,42 @@
 #include <igl/avg_edge_length.h>
 #include <igl/barycenter.h>
 #include <igl/principal_curvature.h>
+#include <igl/jet.h>
 
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
 
 int main(int argc, char *argv[])
 {
+  using namespace Eigen;
   // Load a mesh in OFF format
   igl::readOFF("../shared/fertility.off", V, F);
 
   // Compute curvature directions via quadric fitting
-  Eigen::MatrixXd PD1,PD2,PV1,PV2;
+  MatrixXd PD1,PD2;
+  VectorXd PV1,PV2;
   igl::principal_curvature(V,F,PD1,PD2,PV1,PV2);
 
-  // Plot the mesh
   igl::Viewer viewer;
   viewer.set_mesh(V, F);
 
-  // Find the average edge length
-  double avg = igl::avg_edge_length(V,F);
+  // Compute pseudocolor
+  MatrixXd C;
+  igl::jet(PV1,true,C);
+  viewer.set_colors(C);
+
+  // Average edge length for sizing
+  const double avg = igl::avg_edge_length(V,F);
   
-  // Draw a red segment on each vertex parallel to the minimal curvature direction
-  viewer.add_edges(V + PD1*avg, V - PD1*avg, Eigen::RowVector3d(0,0,1));
+  // Draw a red segment parallel to the minimal curvature direction
+  const RowVector3d red(1,0,0),blue(0,0,1);
+  viewer.add_edges(V + PD1*avg, V - PD1*avg, red);
+
+  // Draw a blue segment parallel to the maximal curvature direction
+  viewer.add_edges(V + PD2*avg, V - PD2*avg, blue);
 
-  // Draw a blue segment on each vertex parallel to the maximal curvature direction
-  viewer.add_edges(V + PD2*avg, V - PD2*avg, Eigen::RowVector3d(1,0,0));
+  // Hide wireframe
+  viewer.options.show_lines = false;
 
-  // Launch the viewer
   viewer.launch();
 }