Sfoglia il codice sorgente

conver mesh example

Former-commit-id: 1e7a4a61079ceac41dd1607d12ef87bab13e9186
Alec Jacobson 10 anni fa
parent
commit
054f629910
2 ha cambiato i file con 51 aggiunte e 0 eliminazioni
  1. 20 0
      examples/convertmesh/Makefile
  2. 31 0
      examples/convertmesh/convertmesh.cpp

+ 20 - 0
examples/convertmesh/Makefile

@@ -0,0 +1,20 @@
+.PHONY: all
+
+# Shared flags etc.
+include ../../build/Makefile.conf
+
+all: convertmesh
+
+.PHONY: convertmesh
+
+INC=$(LIBIGL_INC) $(EIGEN3_INC) 
+LIB=$(LIBIGL_LIB) 
+
+convertmesh: convertmesh.o
+	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) $(LIB) -o convertmesh convertmesh.o 
+
+convertmesh.o: convertmesh.cpp
+	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -c convertmesh.cpp -o convertmesh.o $(INC)
+clean:
+	rm -f convertmesh.o
+	rm -f convertmesh

+ 31 - 0
examples/convertmesh/convertmesh.cpp

@@ -0,0 +1,31 @@
+#include <igl/read_triangle_mesh.h>
+#include <igl/write_triangle_mesh.h>
+#include <string>
+#include <iostream>
+int main(int argc, char * argv[])
+{
+  using namespace std;
+  using namespace Eigen;
+  using namespace igl;
+  MatrixXd V;
+  MatrixXi F;
+  string in,out;
+  switch(argc)
+  {
+    case 3:
+      in = argv[1];
+      out = argv[2];
+      break;
+    default:
+      cerr<<R"(
+USAGE:
+  convertmesh input.[mesh|obj|off|ply|stl|wrl] output.[mesh|obj|off|ply|stl|wrl]
+
+  Note: .ply and .stl outputs are binary.
+)";
+    return EXIT_FAILURE;
+  }
+  return 
+    read_triangle_mesh(in,V,F) && write_triangle_mesh(out,V,F,false) ? 
+    EXIT_SUCCESS : EXIT_FAILURE;
+}