Просмотр исходного кода

moved Core example in a subfolder
added Core examples makefile and readme


Former-commit-id: 9bc6e8db75c972bb05ce8c312d0fc11dbbe1c92d

dpanozzo 13 лет назад
Родитель
Сommit
17bde85654

+ 40 - 0
examples/Core/Makefile

@@ -0,0 +1,40 @@
+
+all: example1 example2
+
+STATIC_ANTTWEAKBAR=""
+
+igl_lib=../../
+eigen_lib=/opt/local/include/eigen3/
+
+ifdef STATIC_ANTTWEAKBAR
+CFLAGS=-g -DSTATIC_ANTTWEAKBAR
+inc=-I$(igl_lib) -I./static -I$(eigen_lib)
+lib= -lAntTweakBar -framework AppKit
+else
+CFLAGS=-g
+inc=-I$(igl_lib) -I$(eigen_lib)
+lib=-lAntTweakBar
+endif
+
+matlablibs=-I/Applications/MATLAB_R2010b.app/extern/include -L/Applications/MATLAB_R2010b.app/bin/maci64/ -leng -lmx
+
+example1: example1.o
+	g++ $(CFLAGS) -o example1 example1.o -framework OpenGL -framework GLUT $(lib)
+	rm example1.o
+
+example1.o: example1.cpp
+	g++ $(CFLAGS) -c example1.cpp -o example1.o $(inc)
+
+example2: example2.o
+	g++ $(CFLAGS) $(matlablibs) -o example2 example2.o -framework OpenGL -framework GLUT $(lib)
+	rm example2.o
+
+example2.o: example2.cpp
+	g++ $(CFLAGS) $(matlablibs) -c example2.cpp -o example2.o $(inc)
+
+clean:
+	rm -f example1.o
+	rm -f example1
+	rm -f example2.o
+	rm -f example2
+	rm -f bunny_out.off

+ 13 - 0
examples/Core/README

@@ -0,0 +1,13 @@
+igl_lib is a lightweight C++ for mesh processing
+
+Example1.cpp: 
+- Load/save a mesh
+- Compute face and edge topology
+- Compute the cotan matrix of the loaded mesh
+
+Example2.cpp:
+- Show how it is possible to send/receive matrices to/from matlab
+in order to use the matlab functions in the igl_toolbox
+
+Tu run example2 you need matlab and to properly configure your PATH and DYLD_PATH.
+See runexample2.sh for an example.

+ 1 - 0
examples/Core/bunny.off.REMOVED.git-id

@@ -0,0 +1 @@
+022b8fd121c540101dd1b2de051e69028c735823

+ 2 - 2
example1.cpp → examples/Core/example1.cpp

@@ -20,7 +20,7 @@ int main (int argc, const char * argv[])
 {
     Eigen::MatrixXd V;
     Eigen::MatrixXi F;
-    igl::read(string(argv[1]),V,F);
+    igl::read("bunny.off",V,F);
 
     std::cout << "Mesh loaded!\n";
     cout << "Vertex Array:" << endl;
@@ -36,7 +36,7 @@ int main (int argc, const char * argv[])
     cout << L << endl;
     cout << "-------------" << endl;
     
-    igl::write(string(argv[2]),V,F);
+    igl::write("bunny_out.off",V,F);
     
     // Face Topology
     cout << "TT Topology:" << endl;

+ 1 - 1
example2.cpp → examples/Core/example2.cpp

@@ -26,7 +26,7 @@ int main (int argc, const char * argv[])
     Eigen::MatrixXi F,F2;
     
     // Read mesh from file
-    igl::read(string(argv[1]),V,F);
+    igl::read("bunny.off",V,F);
     
     // Send mesh to matlab
     igl::mlsetmatrix("V",V);

+ 7 - 0
examples/Core/runexample2.sh

@@ -0,0 +1,7 @@
+PATH=/opt/local/bin:/opt/local/sbin:/Applications/MATLAB_R2010b.app/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin
+DYLD_LIBRARY_PATH=/Applications/MATLAB_R2010b.app/bin/maci64
+
+export PATH
+export DYLD_LIBRARY_PATH
+
+./example2

+ 0 - 55
main.cpp

@@ -1,55 +0,0 @@
-//
-//  IGL Lib - Simple C++ mesh library 
-//
-//  Copyright 2011, Daniele Panozzo. All rights reserved.
-//
-//
-//  Example that shows the integration with matlab
-//
-
-// IMPORTANT DO NOT REMOVE OR MOVE
-#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET 
-
-#include <iostream>
-#include <string>
-#include <read.h>
-
-#include <matlabinterface.h>
-
-using namespace std;
-
-int main (int argc, const char * argv[])
-{
-    // read the header of matlabinterface.h for compilation instructions
-    
-    Eigen::MatrixXd V,V2;
-    Eigen::MatrixXi F,F2;
-    
-    // Read mesh from file
-    igl::read(string(argv[1]),V,F);
-    
-    // Send mesh to matlab
-    igl::mlsetmatrix("V",V);
-    igl::mlsetmatrix("F",F);
-
-    // Plot the mesh from matlab
-    igl::mleval("trimesh(F,V(:,1),V(:,2),V(:,3))");
-
-    // Receive mesh from matlab
-    igl::mlgetmatrix("V",V2);
-    igl::mlgetmatrix("F",F2);
-
-    // Plot the received mesh
-    cerr << "V " << endl << V2  << endl;
-    cerr << "F " << endl << F2  << endl;
-    
-    // It is also possible to send scalars
-    igl::mlsetscalar("s", 3);
-    cerr << "s = " << igl::mlgetscalar("s") << endl;
-
-    // If the program closes the matlab session is killed too..
-    getchar();
-    
-    return 0;
-}
-