Skip to content
This repository was archived by the owner on Oct 16, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ if (NOT LIBIGL_FOUND)
message(FATAL_ERROR "libigl not found --- You can download it using: \n git clone --recursive https://github.com/libigl/libigl.git ${PROJECT_SOURCE_DIR}/../libigl")
endif()

if (NOT EIGEN_FOUND)
find_package(Eigen)
include_directories(Eigen ${EIGEN_INCLUDE_DIRS})
endif (NOT EIGEN_FOUND)

if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /bigobj" ) ### Enable parallel compilation for Visual Studio
set(CMAKE_CXX_FLAGS_RELEASE "/MT")
Expand Down
36 changes: 36 additions & 0 deletions cmake/FindEigen.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# - Find Eigen
# This module searches for the Eigen C++ library.
#
# The module defines the following variables:
# EIGEN_INCLUDE_DIRS, where to find Eigen/Core, etc.
# EIGEN_FOUND, if false, do not try to use EIGEN.
#
# Variables used by this module, they can change the default behavior and need
# to be set before calling find_package:
#
# EIGEN_ROOT_DIR - The prefered installation prefix when searching for Eigen
#

include(FindPackageHandleStandardArgs)

# Finds the include files directory
find_path(EIGEN_INCLUDE_DIRS
NAMES Eigen/Core
HINTS "${EIGEN_ROOT_DIR}"
PATHS
$ENV{EIGEN_INC}
$ENV{EIGEN_PATH}
${PROJECT_SOURCE_DIR}/python/pymesh/third_party/include
/opt/local/include
/usr/local/include
/usr/include
PATH_SUFFIXES eigen3
DOC "The directory where Eigen/Core resides"
NO_DEFAULT_PATH
)

if(EIGEN_INCLUDE_DIRS)
mark_as_advanced(EIGEN_INCLUDE_DIRS)
endif()

FIND_PACKAGE_HANDLE_STANDARD_ARGS(Eigen DEFAULT_MSG EIGEN_INCLUDE_DIRS)
Binary file added data/cube.ply
Binary file not shown.
1,923 changes: 1,923 additions & 0 deletions data/sphere.obj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion include/igl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ file(GLOB TEST_INC_FILES *.h *.inl)

add_executable(igl_tests ${TEST_SRC_FILES} ${TEST_INC_FILES})
target_link_libraries(igl_tests ${COMMON_LIBRARIES})
add_custom_command(TARGET igl_tests POST_BUILD COMMAND igl_tests)
add_custom_target(run_igl_tests ALL igl_tests DEPENDS igl_tests)
103 changes: 0 additions & 103 deletions include/igl/copyleft/boolean/mesh_boolean.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion include/igl/copyleft/cgal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ file(GLOB TEST_INC_FILES *.h *.inl)

add_executable(igl_cgal_tests ${TEST_SRC_FILES} ${TEST_INC_FILES})
target_link_libraries(igl_cgal_tests ${COMMON_LIBRARIES} ${CGAL_LIBRARIES})
add_custom_command(TARGET igl_cgal_tests POST_BUILD COMMAND igl_cgal_tests)
add_custom_target(run_igl_cgal_tests ALL igl_cgal_tests DEPENDS igl_cgal_tests)

57 changes: 57 additions & 0 deletions include/igl/copyleft/cgal/CSGTree.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <test_common.h>

#include <igl/copyleft/cgal/CSGTree.h>
#include <igl/doublearea.h>

TEST(CSGTree, extrusion) {
Eigen::MatrixXd V;
Expand All @@ -15,3 +16,59 @@ TEST(CSGTree, extrusion) {
ASSERT_EQ(V.rows(), V2.rows());
ASSERT_EQ(F.rows(), F2.rows());
}

TEST(CSGTree, cube) {
Eigen::MatrixXd V;
Eigen::MatrixXi F;
test_common::load_mesh("cube.obj", V, F);

igl::copyleft::cgal::CSGTree tree({V, F}, {V, F}, "u");
Eigen::MatrixXd V2 = tree.cast_V<Eigen::MatrixXd>();
Eigen::MatrixXi F2 = tree.F();

ASSERT_EQ(V.rows(), V2.rows());
ASSERT_EQ(F.rows(), F2.rows());
}

TEST(CSGTree, A_minus_B__union__A_intersect_B) {
Eigen::MatrixXd VA, VB;
Eigen::MatrixXi FA, FB;
test_common::load_mesh("cube.obj", VA, FA);
test_common::load_mesh("TinyTorus.obj", VB, FB);

igl::copyleft::cgal::CSGTree tree{
{{VA, FA}, {VB, FB}, "minus"},
{{VA, FA}, {VB, FB}, "intersect"},
"union"
};

Eigen::MatrixXd VC = tree.cast_V<Eigen::MatrixXd>();
Eigen::MatrixXi FC = tree.F();

Eigen::VectorXd area_A, area_C;
igl::doublearea(VA, FA, area_A);
igl::doublearea(VC, FC, area_C);

ASSERT_FLOAT_EQ(area_A.sum(), area_C.sum());
}

TEST(CSGTree, A_xor_B___minus___A_union_B__minus__A_intersect_B) {
Eigen::MatrixXd VA, VB;
Eigen::MatrixXi FA, FB;
test_common::load_mesh("cube.obj", VA, FA);
test_common::load_mesh("decimated-knight.obj", VB, FB);

igl::copyleft::cgal::CSGTree tree{
{{VA, FA}, {VB, FB}, "xor"},
{
{{VA, FA}, {VB, FB}, "union"},
{{VA, FA}, {VB, FB}, "intersect"},
"minus"
}, "minus"
};
Eigen::MatrixXd VC = tree.cast_V<Eigen::MatrixXd>();
Eigen::MatrixXi FC = tree.F();

ASSERT_EQ(0, VC.rows());
ASSERT_EQ(0, FC.rows());
}
Loading