Skip to content

Commit 112d946

Browse files
committed
WIP-FIX: found the bug in open3d we do not import visualizer with different contexts
1 parent 76afb7f commit 112d946

File tree

6 files changed

+92
-114
lines changed

6 files changed

+92
-114
lines changed

.vscode/settings.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@
8686
"span": "cpp",
8787
"stop_token": "cpp",
8888
"thread": "cpp",
89-
"variant": "cpp"
89+
"variant": "cpp",
90+
"bitset": "cpp",
91+
"cfenv": "cpp",
92+
"ranges": "cpp",
93+
"shared_mutex": "cpp",
94+
"source_location": "cpp",
95+
"stack": "cpp",
96+
"valarray": "cpp"
9097
}
9198
}

CMakeLists.txt

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,17 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
1212

1313
include(external_tools)
1414

15+
#FIXME: here we need to use the external function to update the submodules to the
16+
# latest commit
1517
execute_process(COMMAND git submodule update --init --recursive
1618
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
1719
RESULT_VARIABLE GIT_SUBMOD_RESULT
1820
)
21+
# do a git pull to get the latest commit
22+
execute_process(COMMAND git pull
23+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
24+
RESULT_VARIABLE GIT_PULL_RESULT
25+
)
1926
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
2027
message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
2128
endif()
@@ -49,7 +56,7 @@ target_include_directories(${SHARED_LIB_NAME}
4956
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src
5057
)
5158

52-
target_precompile_headers(${SHARED_LIB_NAME} PUBLIC src/diffcheckpch.hh)
59+
# target_precompile_headers(${SHARED_LIB_NAME} PUBLIC src/diffcheckpch.hh)
5360

5461
#--------------------------------------------------------------------------
5562
# 3rd party
@@ -76,13 +83,8 @@ set_target_properties(glfw3 PROPERTIES
7683
INTERFACE_INCLUDE_DIRECTORIES ${GLFW_INCLUDE_PATH}
7784
)
7885

79-
# target_link_directories(${SHARED_LIB_NAME} PUBLIC ${GLFW_LIB_PATH})
80-
# target_link_directories(${SHARED_LIB_NAME} INTERFACE ${GLFW_LIB_PATH})
81-
8286
target_link_libraries(${SHARED_LIB_NAME} PUBLIC glfw3)
83-
# target_link_libraries(${SHARED_LIB_NAME} INTERFACE glfw3)
8487
target_include_directories(${SHARED_LIB_NAME} PUBLIC ${GLFW_INCLUDE_PATH})
85-
# target_include_directories(${SHARED_LIB_NAME} INTERFACE ${GLFW_INCLUDE_PATH})
8688

8789
# TODO: replace with add_subdirectory() instead of binaries
8890
# glew (pre-build binaries) --------------------------------------------------------------
@@ -121,17 +123,13 @@ add_subdirectory(deps/eigen)
121123
target_link_libraries(${SHARED_LIB_NAME} PUBLIC Eigen3::Eigen)
122124
# target_link_libraries(${SHARED_LIB_NAME} INTERFACE Eigen3::Eigen)
123125

124-
#FIXME: might need qt4 for visualizer
125-
126-
127-
128126

129127

130128
# FIXME: no need to specify opnegl because by system and fetched automatically
131129
# # # 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)
130+
find_package(OpenGL REQUIRED)
131+
target_link_libraries(${SHARED_LIB_NAME} PUBLIC OpenGL::GL)
132+
target_link_libraries(${SHARED_LIB_NAME} INTERFACE OpenGL::GL)
135133

136134

137135

@@ -141,19 +139,19 @@ target_link_libraries(${SHARED_LIB_NAME} PUBLIC Eigen3::Eigen)
141139

142140
# HERE'S THE PROBLEEEEEM <<<<<<
143141
# Libigl (header-only) --------------------------------------------------------------
144-
# set a flag
145-
146-
# set target to create igl::glfw
147142

143+
# all dependecies for libigl: https://libigl.github.io/third-party/
144+
# set compiling flags for libigl
145+
set(LIBIGL_USE_STATIC_LIBRARY OFF)
146+
set(LIBIGL_GLFW ON)
147+
add_subdirectory(deps/libigl)
148148

149-
# add_subdirectory(deps/libigl)
149+
target_link_libraries(${SHARED_LIB_NAME} PUBLIC igl::glfw)
150+
# target_link_libraries(${SHARED_LIB_NAME} INTERFACE igl::core igl::opengl igl::opengl_glfw)
150151

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})
152+
# set(LIBIGL_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/deps/libigl/include)
153+
# target_include_directories(${SHARED_LIB_NAME} PUBLIC ${LIBIGL_INCLUDE_PATH})
154+
# target_include_directories(${SHARED_LIB_NAME} INTERFACE ${LIBIGL_INCLUDE_PATH})
157155

158156

159157

@@ -185,8 +183,8 @@ target_include_directories(${SHARED_LIB_NAME} PUBLIC ${OPEN3D_INCLUDE_PATH})
185183

186184

187185

188-
# copy all the dlls to the bin directory
189-
# List of libraries that DiffCheck is linked against
186+
# copy all the dlls to the bin directory to make dll accessible
187+
# List of dynamic libraries that DiffCheck is linked against
190188
set(DEPENDENCIES glfw3 glew32 Open3D)
191189

192190
foreach(DEP_LIB ${DEPENDENCIES})
@@ -198,8 +196,6 @@ foreach(DEP_LIB ${DEPENDENCIES})
198196
endforeach()
199197

200198

201-
202-
203199
#--------------------------------------------------------------------------
204200
# executable
205201
#--------------------------------------------------------------------------

src/diffCheck.cc

Lines changed: 48 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
#pragma once
1+
#include "diffCheck.hh"
22

3-
#include "diffCheck.hh" // This is a dummy include to test the include path
4-
5-
// #include <igl/readPLY.h>
6-
// #include <igl/opengl/glfw/Viewer.h>
7-
8-
#include <open3d/Open3D.h>
3+
// #include <open3d/Open3D.h>
94

105
#include <string>
116
#include <iostream>
@@ -18,33 +13,26 @@ namespace diffCheck {
1813

1914
void testOpen3d()
2015
{
21-
std::shared_ptr<open3d::geometry::PointCloud> cloud(new open3d::geometry::PointCloud());
22-
// print the number of points in the point cloud
23-
std::cout << "Point cloud has " << cloud->points_.size() << " points." << std::endl;
24-
std::cout << "testOpen3d check." << std::endl;
16+
// std::shared_ptr<open3d::geometry::PointCloud> cloud(new open3d::geometry::PointCloud());
17+
// // print the number of points in the point cloud
18+
// std::cout << "Point cloud has " << cloud->points_.size() << " points." << std::endl;
19+
// std::cout << "testOpen3d check." << std::endl;
2520

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();
21+
// // fill the point cloud with random points
22+
// cloud->points_.resize(100);
23+
// for (auto &point : cloud->points_) {
24+
// point = Eigen::Vector3d::Random();
25+
// }
26+
// // set the point cloud color to be light blue
27+
// cloud->colors_.resize(100);
28+
// for (auto &color : cloud->colors_) {
29+
// color = Eigen::Vector3d(0.7, 0.7, 1.0);
30+
// }
31+
// // set the normal of the point cloud
32+
// cloud->normals_.resize(100);
33+
// for (auto &normal : cloud->normals_) {
34+
// normal = Eigen::Vector3d(0.0, 0.0, 1.0);
35+
// }
4836
}
4937

5038
void testLibigl()
@@ -63,34 +51,34 @@ namespace diffCheck {
6351
// viewer.launch();
6452

6553
// ########################################
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();
54+
const Eigen::MatrixXd V= (Eigen::MatrixXd(8,3)<<
55+
0.0,0.0,0.0,
56+
0.0,0.0,1.0,
57+
0.0,1.0,0.0,
58+
0.0,1.0,1.0,
59+
1.0,0.0,0.0,
60+
1.0,0.0,1.0,
61+
1.0,1.0,0.0,
62+
1.0,1.0,1.0).finished();
63+
const Eigen::MatrixXi F = (Eigen::MatrixXi(12,3)<<
64+
0,6,4,
65+
0,2,6,
66+
0,3,2,
67+
0,1,3,
68+
2,7,6,
69+
2,3,7,
70+
4,6,7,
71+
4,7,5,
72+
0,4,5,
73+
0,5,1,
74+
1,5,7,
75+
1,7,3).finished();
8876

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();
77+
// Plot the mesh
78+
igl::opengl::glfw::Viewer viewer;
79+
viewer.data().set_mesh(V, F);
80+
viewer.data().set_face_based(true);
81+
viewer.launch();
9482
}
9583

9684
} // namespace diffCheck

src/diffCheck.hh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
#pragma once
22

3-
#include <GL/glew.h>
4-
#include <GLFW/glfw3.h>
3+
// #include <glad/glad.h>
4+
// #include <GL/glew.h> // Remove this line
5+
// #include <GLFW/glfw3.h>
6+
// #define GLFW_INCLUDE_NONE
7+
// #include <GLFW/glfw3.h>
8+
// #include <glad/gl.h>
9+
10+
11+
12+
#include <igl/readPLY.h>
13+
#include <igl/opengl/glfw/Viewer.h>
514

615
#include <open3d/Open3D.h>
716

8-
#include "diffcheckpch.hh"
17+
18+
919

1020
// #include "diffCheck/glHeader.hh"
1121
#include "diffCheck/libHeaderTemplate.hh" // This is a dummy include to test the include path

src/diffcheckpch.cc

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/diffcheckpch.hh

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)