Browse Source

added a multi scale curvature estimator

Former-commit-id: 5ad27740e72215cf0c555717142e861914a274ce
Daniele Panozzo 11 years ago
parent
commit
4e4f547f1a

+ 24 - 0
examples/principal_curvature/Makefile

@@ -0,0 +1,24 @@
+
+.PHONY: all
+
+# Shared flags etc.
+include ../../Makefile.conf
+
+all: curvature
+
+.PHONY: curvature
+
+igl_lib=../../
+eigen=-I$(DEFAULT_PREFIX)/include/eigen3
+
+CFLAGS=-g
+inc=-I$(igl_lib)/include $(eigen)
+
+curvature: curvature.o
+	g++ $(CFLAGS) -o curvature curvature.o $(lib)
+
+curvature.o: curvature.cpp
+	g++ $(CFLAGS) -c curvature.cpp -o curvature.o $(inc)
+clean:
+	rm -f curvature.o
+	rm -f curvature

+ 9 - 0
examples/principal_curvature/README

@@ -0,0 +1,9 @@
+This is a simple example program that shows how to use the mesh IO functions of
+readOBJ.h etc. in the igl library.
+
+
+To Build:
+  make
+
+To Run:
+  ./example [path_1] [path_2] ... [path_n]

+ 33 - 0
examples/principal_curvature/cube.obj

@@ -0,0 +1,33 @@
+# cube.obj
+#
+ 
+g cube
+ 
+v  0.0  0.0  0.0
+v  0.0  0.0  1.0
+v  0.0  1.0  0.0
+v  0.0  1.0  1.0
+v  1.0  0.0  0.0
+v  1.0  0.0  1.0
+v  1.0  1.0  0.0
+v  1.0  1.0  1.0
+
+vn  0.0  0.0  1.0
+vn  0.0  0.0 -1.0
+vn  0.0  1.0  0.0
+vn  0.0 -1.0  0.0
+vn  1.0  0.0  0.0
+vn -1.0  0.0  0.0
+ 
+f  1//2  7//2  5//2
+f  1//2  3//2  7//2 
+f  1//6  4//6  3//6 
+f  1//6  2//6  4//6 
+f  3//3  8//3  7//3 
+f  3//3  4//3  8//3 
+f  5//5  7//5  8//5 
+f  5//5  8//5  6//5 
+f  1//4  5//4  6//4 
+f  1//4  6//4  2//4 
+f  2//1  6//1  8//1 
+f  2//1  8//1  4//1 

+ 1 - 0
examples/principal_curvature/curvature.REMOVED.git-id

@@ -0,0 +1 @@
+982fd49ae481af158720a1ec35673ee78ea80526

+ 162 - 0
examples/principal_curvature/curvature.cpp

@@ -0,0 +1,162 @@
+
+#define IGL_HEADER_ONLY
+#include <igl/principal_curvature.h>
+#include <igl/read.h>
+#include <iostream>
+#include <Eigen/Dense>
+#include <Eigen/Sparse>
+
+
+using namespace std;
+bool cont=true;
+bool benchmark=false;
+
+void print_help()
+{
+    cout << "Usage: Curvature -i meshfile [-o curvfile] [-S scalefile] "
+            "[-k N | -e F] [-a] [-l] [-p] [-m N] [-s] [-z] [-b] [-n N] [-M N] [-h] \n"
+            "    -k N: compute using the N-ring of vertexes.\n"
+            "    -e S: compute using a sphere of radius R = S * mesh_average_edge.\n"
+            "    -a: no projection plane, use normals average.\n"
+            "    -l: local mode, use vcg normal (when using -a) or incident faces normal (default)\n"
+            "    -p: check projection plane calculation\n"
+            "    -m N: use montecarlo, extract N vertices maximum.\n"
+            "    -b: benchmark mode\n"
+            "    -n N: step for benchmarking\n"
+            "    -M N: max size for benchmarking\n"
+            "    -s: use svd calculation, not pseudoinverse.\n"
+            "    -z: check if determinant is almost zero.\n"
+            "    -h: print this help and exit.\n";
+}
+
+bool isDir(char* file)
+{
+    std::string s(file);
+    return (s.find_last_of('/')==s.size()-1);
+}
+
+void app_init(int argc, char* argv[], CurvatureCalculator& c, Eigen::MatrixXd& V, Eigen::MatrixXi& F)
+{
+    if (argc<2)
+    {
+        print_help();
+        exit(0);
+    }
+    char* tmp;
+    const char* meshName;
+    char * scaleFile;
+    for (argc--, argv++; argc--; argv++)
+    {
+        if( (*argv)[0] == '-')
+        {
+            switch( (*argv)[1] )
+            {
+            case 'b':
+                benchmark=true;
+                break;
+            case 'n':
+                tmp=*++argv;
+                if (!strcmp(tmp,"exp"))
+                    c.expStep=true;
+                else
+                    c.step=atoi(tmp);
+                --argc;
+                break;
+            case 'M':
+                c.maxSize=atoi(*++argv);
+                argc--;
+                break;
+            case 'i':
+                meshName=*++argv;
+                igl::read(meshName,V,F);
+                argc--;
+                break;
+            case 'k':
+                c.st=K_RING_SEARCH;
+                c.kRing = atoi (*++argv);
+                argc--;
+                break;
+
+            case 'e':
+                c.st=SPHERE_SEARCH;
+                c.sphereRadius = atof (*++argv);
+                argc--;
+                break;
+
+            case 'a':
+                c.nt=AVERAGE;
+                break;
+
+            case 'l':
+                c.localMode = true;
+                break;
+
+            case 'p':
+                c.projectionPlaneCheck = true;
+                break;
+
+            case 'm':
+                c.montecarlo=true;
+                c.montecarloN = atoi (*++argv);
+                argc--;
+                break;
+
+            case 's':
+                c.svd = true;
+                break;
+
+            case 'z':
+                c.zeroDetCheck = true;
+                break;
+
+            case 'f':
+                /* dc.fitCreaseMode = atoi (*++argv);
+                    argc--;*/
+                break;
+
+            case 'o':
+                tmp=*++argv;
+                cerr << "Tmp: " << tmp << endl;
+                if (isDir(tmp))
+                {
+                    std::string tmpS(tmp);
+                    std::string tmpM(meshName);
+                    size_t pos=tmpM.find_last_of('/');
+                    tmpM.assign(tmpM.begin()+pos+1,tmpM.end());
+                    c.lastMeshName=tmpS+tmpM;
+                }
+                else
+                    c.lastMeshName=tmp;
+                argc--;
+                break;
+
+            case 'h':
+                print_help();
+                exit(0);
+
+            default:
+                print_help();
+                exit(0);
+            }
+        }
+    }
+
+    return;
+}
+
+int main(int argc, char *argv[])
+{
+    CurvatureCalculator c;
+    Eigen::MatrixXd V;
+    Eigen::MatrixXi F;
+    string filename;
+
+    app_init(argc,argv,c,V,F);
+    
+    c.init(V,F);
+
+    c.computeCurvature();
+
+    c.printCurvature(c.lastMeshName);
+
+}

+ 25 - 0
examples/principal_curvature/out.txt

@@ -0,0 +1,25 @@
+24
+-0.000218818 -0.000132862 -6.78817e-09 0.000218818 -1.92845e-07 -0.000132862 3.32976e-10 -9.24825e-08
+-0.0538474 0.0831989 -0.0510914 -0.000308941 -0.0170034 0.0019243 -0.0831761 -0.000286084
+-0.00139457 -0.000130953 -0.00139456 9.41415e-08 -4.78077e-06 9.18218e-08 0.000130953 -2.96994e-07
+-0.0841741 0.0530543 -0.000748788 -0.0841707 -0.000109605 -0.0503929 0.000116904 0.0165923
+-0.00310069 -0.00188096 0.00268527 -0.00155034 1.84798e-08 -0.000940441 -0.00162888 -1.85467e-05
+-0.0484876 0.089561 -0.0231571 -0.0401105 -0.0143508 0.0775325 -0.0448318 1.84107e-05
+-0.000160861 -1.52859e-05 8.04361e-05 0.000139307 6.36278e-08 -1.32384e-05 7.64215e-06 4.62445e-08
+-0.0737388 0.0631252 0.0635708 -0.0373626 -0.000451008 0.0293621 0.0514143 -0.0218912
+0.000121414 0.000200183 6.07005e-05 -0.000105151 7.7354e-08 0.000173362 0.000100093 -4.22956e-07
+-0.0629872 0.0699502 0.0295383 -0.0509979 -0.0222282 0.0594538 0.0368472 -0.000748106
+0.000190518 0.00202128 -0.000164893 -9.5429e-05 -8.43491e-07 -0.00100931 0.00175122 -1.00438e-05
+-0.0768909 0.0590056 0.0663809 0.0388031 0.000326118 -0.0276308 0.0482486 -0.0197554
+-0.00242621 -0.00147083 6.17144e-07 0.00242619 -9.05158e-06 0.00147079 1.9341e-06 -1.13541e-05
+-0.0521247 0.0815705 0.0494606 -1.982e-06 -0.016451 -0.00257863 0.0815256 -0.000824655
+-0.00142792 -0.00013425 -0.00142791 9.18455e-08 5.01237e-06 1.30109e-08 -0.00013425 7.56947e-08
+-0.085571 0.0510784 -0.000667473 0.0855668 0.000525293 -0.0486106 0.000284385 -0.0156824
+-0.00213635 -0.00129677 -0.00185028 0.00106789 5.31779e-06 0.000649237 0.0011225 -8.81571e-06
+-0.0393564 0.0965974 0.0189833 0.0328145 -0.0105721 -0.0849551 0.045968 -0.000787047
+-0.000355207 -3.35712e-05 -0.000177636 -0.000307599 3.10083e-07 2.9076e-05 -1.67808e-05 1.26306e-07
+-0.0738809 0.0643355 -0.0631841 0.0382707 -0.00123142 -0.029482 -0.0526071 -0.0224135
+-0.00113106 -0.000686469 0.000979539 0.000565515 6.34569e-07 0.000343288 -0.000594464 2.47012e-06
+-0.0633929 0.0744678 -0.0294987 0.0516459 -0.021936 0.0639781 0.0381037 0.000607191
+-0.00122884 -0.000115239 -0.000614087 0.00106439 -3.71038e-06 -9.97896e-05 -5.76375e-05 -2.29586e-07
+-0.0888118 0.0483949 -0.0771786 -0.0439427 -0.000166018 -0.0231098 0.0400164 0.0143771

+ 88 - 0
examples/principal_curvature/torus.obj

@@ -0,0 +1,88 @@
+####
+#
+# OBJ File Generated by Meshlab
+#
+####
+# Object TinyTorus.obj
+#
+# Vertices: 24
+# Faces: 48
+#
+####
+v -2.000000 0.000000 0.000000
+v -3.000000 0.000000 -1.000000
+v -4.000000 0.000000 -0.000001
+v -3.000000 0.000000 1.000000
+v -1.000000 -1.732050 0.000000
+v -1.500000 -2.598080 -1.000000
+v -2.000000 -3.464100 -0.000001
+v -1.500000 -2.598080 1.000000
+v 1.000000 -1.732050 0.000000
+v 1.500000 -2.598080 -1.000000
+v 2.000000 -3.464100 -0.000001
+v 1.500000 -2.598080 1.000000
+v 2.000000 0.000000 0.000000
+v 3.000000 0.000000 -1.000000
+v 4.000000 0.000000 -0.000001
+v 3.000000 0.000000 1.000000
+v 1.000000 1.732050 0.000000
+v 1.500000 2.598080 -1.000000
+v 2.000000 3.464100 -0.000001
+v 1.500000 2.598080 1.000000
+v -1.000000 1.732050 0.000000
+v -1.500000 2.598080 -1.000000
+v -2.000000 3.464100 -0.000001
+v -1.500000 2.598080 1.000000
+# 24 vertices, 0 vertices normals
+
+f 2 1 6
+f 5 6 1
+f 3 2 7
+f 6 7 2
+f 4 3 8
+f 7 8 3
+f 1 4 5
+f 8 5 4
+f 6 5 10
+f 9 10 5
+f 7 6 11
+f 10 11 6
+f 8 7 12
+f 11 12 7
+f 5 8 9
+f 12 9 8
+f 10 9 14
+f 13 14 9
+f 11 10 15
+f 14 15 10
+f 12 11 16
+f 15 16 11
+f 9 12 13
+f 16 13 12
+f 14 13 18
+f 17 18 13
+f 15 14 19
+f 18 19 14
+f 16 15 20
+f 19 20 15
+f 13 16 17
+f 20 17 16
+f 18 17 22
+f 21 22 17
+f 19 18 23
+f 22 23 18
+f 20 19 24
+f 23 24 19
+f 17 20 21
+f 24 21 20
+f 22 21 2
+f 1 2 21
+f 23 22 3
+f 2 3 22
+f 24 23 4
+f 3 4 23
+f 21 24 1
+f 4 1 24
+# 48 faces, 0 coords texture
+
+# End of File