Skip to content

Commit 351b007

Browse files
committed
Initial commit
1 parent f87a2cd commit 351b007

File tree

1,471 files changed

+256217
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,471 files changed

+256217
-1
lines changed

AVX_math.h

Lines changed: 552 additions & 0 deletions
Large diffs are not rendered by default.

CMakeLists.txt

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
cmake_minimum_required(VERSION 3.1)
2+
3+
project(FastCorotDemo)
4+
5+
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules" ${CMAKE_MODULE_PATH})
6+
set(PROJECT_PATH ${PROJECT_SOURCE_DIR})
7+
include_directories(${PROJECT_SOURCE_DIR})
8+
9+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
10+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/bin")
11+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/bin")
12+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_SOURCE_DIR}/bin")
13+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_SOURCE_DIR}/bin")
14+
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
15+
set(CMAKE_DEBUG_POSTFIX "_d")
16+
set(CMAKE_RELWITHDEBINFO_POSTFIX "_rd")
17+
set(CMAKE_MINSIZEREL_POSTFIX "_ms")
18+
19+
set(SOURCES
20+
main.cpp
21+
FastCorotFEM.cpp
22+
TetModel.cpp
23+
utilities/TetGenLoader.cpp
24+
utilities/MiniGL.cpp
25+
)
26+
27+
set(HEADERS
28+
AVX_math.h
29+
FastCorotFEM.h
30+
Common.h
31+
utilities/TetGenLoader.h
32+
utilities/MiniGL.h
33+
utilities/Timing.h
34+
TetModel.h
35+
)
36+
37+
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
38+
add_compile_options(/arch:AVX)
39+
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
40+
add_compile_options("-mavx")
41+
endif()
42+
43+
set(EIGEN3_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/extern/eigen")
44+
find_package( Eigen3 REQUIRED )
45+
46+
# Set include directories.
47+
include_directories(
48+
${EIGEN3_INCLUDE_DIR}
49+
)
50+
51+
# OpenGL & GLEW library
52+
find_package(OpenGL)
53+
54+
# executable
55+
add_executable(FastCorotDemo
56+
${HEADERS}
57+
${SOURCES}
58+
)
59+
60+
if (WIN32)
61+
subdirs(extern/freeglut)
62+
include_directories(${PROJECT_PATH}/extern/freeglut/include)
63+
64+
set(GLUT_LIBRARIES freeglut)
65+
add_dependencies(FastCorotDemo freeglut)
66+
else()
67+
find_package(GLUT REQUIRED)
68+
endif()
69+
70+
target_link_libraries(FastCorotDemo ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
71+
72+
add_definitions(-DDATA_PATH="${PROJECT_PATH}/meshes/")

Common.h

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#ifndef COMMON_H
2+
#define COMMON_H
3+
4+
#include <Eigen/Dense>
5+
#include "float.h"
6+
#define _USE_MATH_DEFINES
7+
#include <cmath>
8+
9+
10+
#define USE_DOUBLE
11+
#define MIN_PARALLEL_SIZE 64
12+
13+
#ifdef USE_DOUBLE
14+
typedef double Real;
15+
16+
#define REAL_MAX DBL_MAX
17+
#define REAL_MIN DBL_MIN
18+
#else
19+
typedef float Real;
20+
21+
#define REAL_MAX FLT_MAX
22+
#define REAL_MIN FLT_MIN
23+
#endif
24+
25+
using Vector2r = Eigen::Matrix<Real, 2, 1>;
26+
using Vector3r = Eigen::Matrix<Real, 3, 1>;
27+
using Vector4r = Eigen::Matrix<Real, 4, 1>;
28+
using Vector6r = Eigen::Matrix<Real, 6, 1>;
29+
using Vector9r = Eigen::Matrix<Real, 9, 1>;
30+
using VectorXr = Eigen::Matrix<Real, Eigen::Dynamic, 1>;
31+
using Matrix2r = Eigen::Matrix<Real, 2, 2>;
32+
using Matrix3r = Eigen::Matrix<Real, 3, 3>;
33+
using Matrix4r = Eigen::Matrix<Real, 4, 4>;
34+
using Matrix6r = Eigen::Matrix<Real, 6, 6>;
35+
using Matrix9r = Eigen::Matrix<Real, 9, 9>;
36+
using MatrixXr = Eigen::Matrix<Real, Eigen::Dynamic, Eigen::Dynamic>;
37+
using AlignedBox2r = Eigen::AlignedBox<Real, 2>;
38+
using AlignedBox3r = Eigen::AlignedBox<Real, 3>;
39+
using AngleAxisr = Eigen::AngleAxis<Real>;
40+
using Quaternionr = Eigen::Quaternion<Real>;
41+
42+
//allocators to be used in STL collections containing Eigen structures
43+
using Alloc_Vector2r = Eigen::aligned_allocator<Vector2r>;
44+
using Alloc_Vector3r = Eigen::aligned_allocator<Vector3r>;
45+
using Alloc_Vector4r = Eigen::aligned_allocator<Vector4r>;
46+
using Alloc_Matrix2r = Eigen::aligned_allocator<Matrix2r>;
47+
using Alloc_Matrix3r = Eigen::aligned_allocator<Matrix3r>;
48+
using Alloc_Matrix4r = Eigen::aligned_allocator<Matrix4r>;
49+
using Alloc_AlignedBox2r = Eigen::aligned_allocator<AlignedBox2r>;
50+
using Alloc_AlignedBox3r = Eigen::aligned_allocator<AlignedBox3r>;
51+
using Alloc_AngleAxisr = Eigen::aligned_allocator<AngleAxisr>;
52+
using Alloc_Quaternionr = Eigen::aligned_allocator<Quaternionr>;
53+
54+
#if EIGEN_ALIGN
55+
#define PDB_MAKE_ALIGNED_OPERATOR_NEW EIGEN_MAKE_ALIGNED_OPERATOR_NEW
56+
#define REPORT_MEMORY_LEAKS
57+
58+
#if defined(WIN32) || defined(_WIN32) || defined(WIN64)
59+
#ifdef _DEBUG
60+
// Enable memory leak detection for Eigen new
61+
#undef PDB_MAKE_ALIGNED_OPERATOR_NEW
62+
#define PDB_MAKE_ALIGNED_OPERATOR_NEW EIGEN_MAKE_ALIGNED_OPERATOR_NEW \
63+
void *operator new(size_t size, int const block_use, char const* file_name, int const line_number) { \
64+
\
65+
return _aligned_malloc_dbg(size, 16, file_name, line_number); \
66+
} \
67+
void *operator new[](size_t size, int const block_use, char const* file_name, int const line_number) { \
68+
return operator new(size, block_use, file_name, line_number); \
69+
}\
70+
void operator delete(void* block, int const block_use, char const* file_name, int const line_number) { \
71+
\
72+
return _aligned_free_dbg(block); \
73+
} \
74+
void operator delete[](void* block, int const block_use, char const* file_name, int const line_number) { \
75+
return operator delete(block, block_use, file_name, line_number); \
76+
}
77+
#endif
78+
#endif
79+
#else
80+
#define PDB_MAKE_ALIGNED_OPERATOR_NEW
81+
82+
#if defined(WIN32) || defined(_WIN32) || defined(WIN64)
83+
// Enable memory leak detection
84+
#ifdef _DEBUG
85+
#define _CRTDBG_MAP_ALLOC
86+
#include <stdlib.h>
87+
#include <crtdbg.h>
88+
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
89+
#define REPORT_MEMORY_LEAKS _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
90+
#else
91+
#define REPORT_MEMORY_LEAKS
92+
#endif
93+
#else
94+
#define REPORT_MEMORY_LEAKS
95+
#endif
96+
97+
#endif
98+
99+
100+
#endif
101+
102+
#if defined(WIN32) || defined(_WIN32) || defined(WIN64)
103+
#define FORCE_INLINE __forceinline
104+
#else
105+
#define FORCE_INLINE __attribute__((always_inline))
106+
#endif
107+
108+

0 commit comments

Comments
 (0)