Skip to content

Commit 76afb7f

Browse files
committed
WIP-CAP: no need for interface, need cleaning, trying to link libigl
1 parent dc444b0 commit 76afb7f

File tree

7 files changed

+153
-22
lines changed

7 files changed

+153
-22
lines changed

.gitmodules

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@
1313
url = https://github.com/fmtlib/fmt.git
1414
[submodule "deps/glew"]
1515
path = deps/glew
16-
url = https://github.com/diffCheckOrg/submodule-glew.git
16+
url = https://github.com/diffCheckOrg/submodule-glew.git
17+
[submodule "deps/libigl"]
18+
path = deps/libigl
19+
url = https://github.com/libigl/libigl.git

CMakeLists.txt

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ target_precompile_headers(${SHARED_LIB_NAME} PUBLIC src/diffcheckpch.hh)
5959

6060

6161

62+
63+
6264
# FIXME: problems with glfw (LINK : fatal error LNK1104: cannot open file '..\deps\glew\win\2_2_0\bin\Release\x64\glew32.obj' [F:\diffCheck\build\diffCheck.vcxproj])
6365
# glfw (pre-build binaries) --------------------------------------------------------------
6466

@@ -78,15 +80,9 @@ set_target_properties(glfw3 PROPERTIES
7880
# target_link_directories(${SHARED_LIB_NAME} INTERFACE ${GLFW_LIB_PATH})
7981

8082
target_link_libraries(${SHARED_LIB_NAME} PUBLIC glfw3)
81-
target_link_libraries(${SHARED_LIB_NAME} INTERFACE glfw3)
83+
# target_link_libraries(${SHARED_LIB_NAME} INTERFACE glfw3)
8284
target_include_directories(${SHARED_LIB_NAME} PUBLIC ${GLFW_INCLUDE_PATH})
83-
target_include_directories(${SHARED_LIB_NAME} INTERFACE ${GLFW_INCLUDE_PATH})
84-
85-
# #find openGL
86-
# find_package(OpenGL REQUIRED)
87-
# target_link_libraries(${SHARED_LIB_NAME} PUBLIC OpenGL::GL)
88-
# target_link_libraries(${SHARED_LIB_NAME} INTERFACE OpenGL::GL)
89-
85+
# target_include_directories(${SHARED_LIB_NAME} INTERFACE ${GLFW_INCLUDE_PATH})
9086

9187
# TODO: replace with add_subdirectory() instead of binaries
9288
# glew (pre-build binaries) --------------------------------------------------------------
@@ -109,23 +105,66 @@ set_target_properties(glew32 PROPERTIES
109105
# target_link_directories(${SHARED_LIB_NAME} INTERFACE ${GLEW_LIB_PATH})
110106

111107
target_link_libraries(${SHARED_LIB_NAME} PUBLIC glew32)
112-
target_link_libraries(${SHARED_LIB_NAME} INTERFACE glew32)
108+
# target_link_libraries(${SHARED_LIB_NAME} INTERFACE glew32)
113109
target_include_directories(${SHARED_LIB_NAME} PUBLIC ${GLEW_INCLUDE_PATH})
114-
target_include_directories(${SHARED_LIB_NAME} INTERFACE ${GLEW_INCLUDE_PATH})
110+
# target_include_directories(${SHARED_LIB_NAME} INTERFACE ${GLEW_INCLUDE_PATH})
115111

116112
# fmt (header-only)--------------------------------------------------------------
117113
add_subdirectory(deps/fmt)
118114

119115
target_link_libraries(${SHARED_LIB_NAME} PUBLIC fmt::fmt)
120-
target_link_libraries(${SHARED_LIB_NAME} INTERFACE fmt::fmt)
116+
# target_link_libraries(${SHARED_LIB_NAME} INTERFACE fmt::fmt)
121117

122118
# Eigen (header-only)--------------------------------------------------------------
123119
add_subdirectory(deps/eigen)
124120

125121
target_link_libraries(${SHARED_LIB_NAME} PUBLIC Eigen3::Eigen)
126-
target_link_libraries(${SHARED_LIB_NAME} INTERFACE Eigen3::Eigen)
122+
# target_link_libraries(${SHARED_LIB_NAME} INTERFACE Eigen3::Eigen)
123+
124+
#FIXME: might need qt4 for visualizer
125+
126+
127+
128+
129+
130+
# FIXME: no need to specify opnegl because by system and fetched automatically
131+
# # # OpenGL (from system) --------------------------------------------------------------
132+
# find_package(OpenGL REQUIRED)
133+
# target_link_libraries(${SHARED_LIB_NAME} PUBLIC OpenGL::GL)
134+
# target_link_libraries(${SHARED_LIB_NAME} INTERFACE OpenGL::GL)
135+
136+
137+
127138

128-
# Open3D (pre-build binaries)--------------------------------------------------------------
139+
140+
141+
142+
# HERE'S THE PROBLEEEEEM <<<<<<
143+
# Libigl (header-only) --------------------------------------------------------------
144+
# set a flag
145+
146+
# set target to create igl::glfw
147+
148+
149+
# add_subdirectory(deps/libigl)
150+
151+
# # avoid to link with glad
152+
# target_link_libraries(${SHARED_LIB_NAME} PUBLIC igl::glfw)
153+
# target_link_libraries(${SHARED_LIB_NAME} INTERFACE igl::glfw)
154+
set(LIBIGL_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/deps/libigl/include)
155+
target_include_directories(${SHARED_LIB_NAME} PUBLIC ${LIBIGL_INCLUDE_PATH})
156+
target_include_directories(${SHARED_LIB_NAME} INTERFACE ${LIBIGL_INCLUDE_PATH})
157+
158+
159+
160+
161+
162+
163+
164+
165+
166+
167+
# Open3D (pre-build binaries /headless not visuals)--------------------------------------------------------------
129168
set(O3D_VERSION 0_17) # 0.17.0
130169
set(OPEN3D_SHAREDLIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/deps/open3d/win/${O3D_VERSION}/bin)
131170
set(OPEN3D_LIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/deps/open3d/win/${O3D_VERSION}/lib)
@@ -138,15 +177,10 @@ set_target_properties(Open3D PROPERTIES
138177
INTERFACE_INCLUDE_DIRECTORIES ${OPEN3D_INCLUDE_PATH}
139178
)
140179

141-
# target_link_directories(${SHARED_LIB_NAME} PUBLIC ${OPEN3D_LIB_PATH})
142-
# target_link_directories(${SHARED_LIB_NAME} INTERFACE ${OPEN3D_LIB_PATH})
143-
# # target_link_directories(${SHARED_LIB_NAME} PUBLIC ${OPEN3D_SHAREDLIB_PATH})
144-
# # target_link_directories(${SHARED_LIB_NAME} INTERFACE ${OPEN3D_SHAREDLIB_PATH})
145-
146180
target_link_libraries(${SHARED_LIB_NAME} PUBLIC Open3D)
147-
target_link_libraries(${SHARED_LIB_NAME} INTERFACE Open3D)
181+
# target_link_libraries(${SHARED_LIB_NAME} INTERFACE Open3D)
148182
target_include_directories(${SHARED_LIB_NAME} PUBLIC ${OPEN3D_INCLUDE_PATH})
149-
target_include_directories(${SHARED_LIB_NAME} INTERFACE ${OPEN3D_INCLUDE_PATH})
183+
# target_include_directories(${SHARED_LIB_NAME} INTERFACE ${OPEN3D_INCLUDE_PATH})
150184

151185

152186

deps/libigl

Submodule libigl added at 81180a6

src/diffCheck.cc

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
#include "diffCheck.hh" // This is a dummy include to test the include path
44

5+
// #include <igl/readPLY.h>
6+
// #include <igl/opengl/glfw/Viewer.h>
7+
58
#include <open3d/Open3D.h>
69

710
#include <string>
@@ -19,6 +22,75 @@ namespace diffCheck {
1922
// print the number of points in the point cloud
2023
std::cout << "Point cloud has " << cloud->points_.size() << " points." << std::endl;
2124
std::cout << "testOpen3d check." << std::endl;
25+
26+
// fill the point cloud with random points
27+
cloud->points_.resize(100);
28+
for (auto &point : cloud->points_) {
29+
point = Eigen::Vector3d::Random();
30+
}
31+
// set the point cloud color to be light blue
32+
cloud->colors_.resize(100);
33+
for (auto &color : cloud->colors_) {
34+
color = Eigen::Vector3d(0.7, 0.7, 1.0);
35+
}
36+
// set the normal of the point cloud
37+
cloud->normals_.resize(100);
38+
for (auto &normal : cloud->normals_) {
39+
normal = Eigen::Vector3d(0.0, 0.0, 1.0);
40+
}
41+
42+
// std::shared_ptr<open3d::visualization::Visualizer> vis(new open3d::visualization::Visualizer());
43+
// vis->CreateVisualizerWindow("Open3DVis", 1000, 800, 500, 200);
44+
// vis->AddGeometry(cloud);
45+
// vis->GetRenderOption().background_color_ = Eigen::Vector3d(1, 1, 1);
46+
// vis->Run();
47+
// vis->DestroyVisualizerWindow();
48+
}
49+
50+
void testLibigl()
51+
{
52+
// // test pcd --------------
53+
// // Now you can use libigl
54+
// igl::opengl::glfw::Viewer viewer;
55+
56+
// Eigen::MatrixXd V;
57+
// Eigen::MatrixXi F;
58+
// // Load a mesh in OFF format
59+
// igl::readPLY("bunny.ply", V, F);
60+
61+
// // Plot the mesh
62+
// viewer.data().set_mesh(V, F);
63+
// viewer.launch();
64+
65+
// ########################################
66+
// const Eigen::MatrixXd V= (Eigen::MatrixXd(8,3)<<
67+
// 0.0,0.0,0.0,
68+
// 0.0,0.0,1.0,
69+
// 0.0,1.0,0.0,
70+
// 0.0,1.0,1.0,
71+
// 1.0,0.0,0.0,
72+
// 1.0,0.0,1.0,
73+
// 1.0,1.0,0.0,
74+
// 1.0,1.0,1.0).finished();
75+
// const Eigen::MatrixXi F = (Eigen::MatrixXi(12,3)<<
76+
// 0,6,4,
77+
// 0,2,6,
78+
// 0,3,2,
79+
// 0,1,3,
80+
// 2,7,6,
81+
// 2,3,7,
82+
// 4,6,7,
83+
// 4,7,5,
84+
// 0,4,5,
85+
// 0,5,1,
86+
// 1,5,7,
87+
// 1,7,3).finished();
88+
89+
// // Plot the mesh
90+
// igl::opengl::glfw::Viewer viewer;
91+
// viewer.data().set_mesh(V, F);
92+
// viewer.data().set_face_based(true);
93+
// viewer.launch();
2294
}
2395

2496
} // namespace diffCheck

src/diffCheck.hh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
#pragma once
22

3+
#include <GL/glew.h>
4+
#include <GLFW/glfw3.h>
5+
6+
#include <open3d/Open3D.h>
7+
8+
#include "diffcheckpch.hh"
9+
10+
// #include "diffCheck/glHeader.hh"
311
#include "diffCheck/libHeaderTemplate.hh" // This is a dummy include to test the include path
412

513
namespace diffCheck {
6-
714
/// @brief Function 1 of the library
815
int func1();
916

@@ -16,4 +23,7 @@ namespace diffCheck {
1623
/// @brief Testing open3d import
1724
void testOpen3d();
1825

26+
/// @brief Testing libigl import
27+
void testLibigl();
28+
1929
} // namespace diffCheck

src/diffCheck/glHeader.hh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
3+
// TODO: put this in the precompiled aiacpch.h file (?)
4+
5+
// <GL/glew.h> has to be included before <GLFW/glfw3.h>
6+
#include <GL/glew.h>
7+
#include <GLFW/glfw3.h>

src/diffCheckApp.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
12
#include "diffCheck.hh"
23

4+
35
int main() {
46
diffCheck::func1();
57
diffCheck::func2();
68
diffCheck::func3();
79

810
diffCheck::testOpen3d();
911

12+
diffCheck::testLibigl();
13+
1014
return 0;
1115
}

0 commit comments

Comments
 (0)