Przeglądaj źródła

* added partial tutorial example for tetgen

Former-commit-id: baf626f65546979eccb8ad6dbf68029b8f94fa98
Daniele Panozzo 11 lat temu
rodzic
commit
2a3196e770

+ 6 - 6
include/igl/barycenter.h

@@ -1,9 +1,9 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
 #ifndef IGL_BARYCENTER_H
 #define IGL_BARYCENTER_H
@@ -15,11 +15,11 @@ namespace igl
   //
   // B = barycenter(V,F)
   //
-  // Compute the barycenter of every triangle
+  // Compute the barycenter of every simplex
   //
   // Inputs:
   //   V #V x dim matrix of vertex coordinates
-  //   F #F x simplex_size  matrix of indices of triangle corners
+  //   F #F x simplex_size  matrix of indices of simplex corners
   // Output:
   //   BC a #F x dim matrix of 3d vertices
   template <

+ 14 - 0
tutorial/605_Tetgen/CMakeLists.txt

@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 2.6)
+project(605_Tetgen)
+
+include("../CMakeLists.shared")
+find_package(TETGEN REQUIRED)
+
+include_directories( ${TETGEN_INCLUDE_DIR})
+
+set(SOURCES
+${PROJECT_SOURCE_DIR}/main.cpp
+)
+
+add_executable(${CMAKE_PROJECT_NAME} ${SOURCES} ${SHARED_SOURCES} ${TETGEN_SOURCES})
+target_link_libraries(${CMAKE_PROJECT_NAME} ${SHARED_LIBRARIES})

+ 31 - 0
tutorial/605_Tetgen/main.cpp

@@ -0,0 +1,31 @@
+#include <igl/viewer/Viewer.h>
+#include <igl/tetgen/tetrahedralize.h>
+#include <igl/readOFF.h>
+
+// Input polygon
+Eigen::MatrixXd V;
+Eigen::MatrixXi F;
+
+// Tetrahedralized interior
+Eigen::MatrixXd TV;
+Eigen::MatrixXi TT;
+Eigen::MatrixXi TF;
+
+int main(int argc, char *argv[])
+{
+  using namespace Eigen;
+  using namespace std;
+
+  // Load a surface mesh
+  igl::readOFF("../shared/fertility.off",V,F);
+  
+  // Tetrahedralize the interior
+  igl::tetrahedralize(V,F,"pq1.414", TV,TT,TF);
+
+  // Compute berycenters
+  
+  // Plot the generated mesh
+  igl::Viewer viewer;
+  viewer.set_mesh(V,F);
+  viewer.launch();
+}

+ 26 - 0
tutorial/cmake/FindTETGEN.cmake

@@ -0,0 +1,26 @@
+# - Try to find the TETGEN library
+# Once done this will define
+#
+#  TETGEN_FOUND - system has TETGEN
+#  TETGEN_INCLUDE_DIR - the TETGEN include directory
+#  TETGEN_SOURCES - the TETGEN source files
+
+FIND_PATH(TETGEN_INCLUDE_DIR tetgen.h
+   /usr/include
+   /usr/local/include
+   ${PROJECT_SOURCE_DIR}/../libigl/external/tetgen/
+   ${PROJECT_SOURCE_DIR}/../../external/tetgen/
+   NO_DEFAULT_PATH
+)
+
+set(TETGEN_SOURCES ${TETGEN_INCLUDE_DIR}/tetgen.cxx ${TETGEN_INCLUDE_DIR}/predicates.cxx)
+
+if(TETGEN_INCLUDE_DIR)
+   message(STATUS "Found TETGEN: ${TETGEN_INCLUDE_DIR}")
+else(TETGEN_INCLUDE_DIR)
+   message(FATAL_ERROR "could NOT find TETGEN")
+endif(TETGEN_INCLUDE_DIR)
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTETLIBRARY")
+
+MARK_AS_ADVANCED(TETGEN_INCLUDE_DIR TETGEN_LIBRARIES TETGEN_SOURCES)