Skip to content

Commit 5b93628

Browse files
committed
wip: pass test after get rid of some
1 parent a73bc9d commit 5b93628

File tree

19 files changed

+304
-159
lines changed

19 files changed

+304
-159
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,6 @@ cython_debug/
259259
#######################################
260260
# get rid of output folder
261261
_build/
262+
263+
# macos
264+
.DS_Store

CMakeLists.txt

Lines changed: 92 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
cmake_minimum_required(VERSION 3.16.)
22
project(diffCheck VERSION 1.3.0 LANGUAGES CXX C)
33
set(CMAKE_CXX_STANDARD 17)
4+
# set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
5+
6+
# Force usage of libc++ and proper visibility on macOS
7+
# For some reason, without this, there will be a segfault in test
8+
if(APPLE)
9+
add_compile_options(-stdlib=libc++ -fvisibility=hidden -Wall)
10+
add_link_options(-stdlib=libc++)
11+
endif()
12+
13+
# # Set rpath for Python extension loading on macOS
14+
# set(CMAKE_MACOSX_RPATH ON)
415

516
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
617

@@ -40,27 +51,31 @@ endif()
4051
set(SHARED_LIB_NAME diffCheck)
4152

4253
file(GLOB_RECURSE SOURCES_LIB
43-
src/diffCheck.hh # diffCheck interface
44-
src/diffCheck/*.cc src/diffCheck/*.hh # diffCheck src
45-
)
46-
47-
add_library(${SHARED_LIB_NAME} SHARED ${SOURCES_LIB})
54+
src/diffCheck.hh # diffCheck interface
55+
src/diffCheck/*.cc src/diffCheck/*.hh # diffCheck src
56+
src/diffCheck/*/*.cc src/diffCheck/*/*.hh # diffCheck submodules
57+
)
58+
59+
# print the sources founded
60+
add_library(${SHARED_LIB_NAME} STATIC ${SOURCES_LIB})
61+
62+
# if (WIN32)
63+
# set_target_properties(${SHARED_LIB_NAME} PROPERTIES
64+
# WINDOWS_EXPORT_ALL_SYMBOLS TRUE
65+
# )
66+
# endif()
67+
set_target_properties(${SHARED_LIB_NAME} PROPERTIES
68+
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
69+
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
70+
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
71+
)
4872

49-
if (WIN32)
50-
set_target_properties(${SHARED_LIB_NAME} PROPERTIES
51-
WINDOWS_EXPORT_ALL_SYMBOLS TRUE
52-
)
53-
endif()
54-
set_target_properties(${SHARED_LIB_NAME} PROPERTIES
55-
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin # for dll
56-
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib # for lib
57-
)
5873
target_include_directories(${SHARED_LIB_NAME}
5974
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src
60-
)
75+
)
6176

6277
#set the MD_DynamicRelease flag for MSVC since we are compiling with /MD for py wrap
63-
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
78+
# set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
6479

6580

6681
#--------------------------------------------------------------------------
@@ -73,29 +88,31 @@ add_subdirectory(deps/eigen)
7388
target_link_libraries(${SHARED_LIB_NAME} PUBLIC Eigen3::Eigen)
7489

7590
# Open3D (pre-built binaries) ---------------------------------------------
76-
download_submodule_project(open3d)
77-
set(Open3D_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/open3d/win/0_18/CMake)
78-
find_package(Open3D 0.18.0 REQUIRED)
91+
# download_submodule_project(open3d)
92+
# set(Open3D_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/open3d/win/0_18/CMake)
93+
# find_package(Open3D 0.18.0 REQUIRED)
94+
95+
# # print the version debug or release of the package
96+
# message(STATUS "Open3D version: ${Open3D_VERSION}"
97+
# "Open3D include dir: ${Open3D_INCLUDE_DIRS}"
98+
# "Open3D library dir: ${Open3D_LIBRARIES}")
7999

80-
# print the version debug or release of the package
81-
message(STATUS "Open3D version: ${Open3D_VERSION}"
82-
"Open3D include dir: ${Open3D_INCLUDE_DIRS}"
83-
"Open3D library dir: ${Open3D_LIBRARIES}")
84100

101+
find_package(Open3D HINTS ${CMAKE_INSTALL_PREFIX}/lib/cmake)
85102
# link the release version of the open3d library
86103
target_link_libraries(${SHARED_LIB_NAME} PUBLIC Open3D::Open3D)
87104

88105
# On Windows if BUILD_SHARED_LIBS is enabled, copy .dll files to the executable directory
89-
if(WIN32)
90-
get_target_property(open3d_type Open3D::Open3D TYPE)
91-
if(open3d_type STREQUAL "SHARED_LIBRARY")
92-
message(STATUS "Copying Open3D.dll to ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}")
93-
add_custom_command(TARGET ${SHARED_LIB_NAME} POST_BUILD
94-
COMMAND ${CMAKE_COMMAND} -E copy
95-
$<TARGET_FILE:Open3D::Open3D>
96-
$<TARGET_FILE_DIR:${SHARED_LIB_NAME}>)
97-
endif()
98-
endif()
106+
# if(WIN32)
107+
# get_target_property(open3d_type Open3D::Open3D TYPE)
108+
# if(open3d_type STREQUAL "SHARED_LIBRARY")
109+
# message(STATUS "Copying Open3D.dll to ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}")
110+
# add_custom_command(TARGET ${SHARED_LIB_NAME} POST_BUILD
111+
# COMMAND ${CMAKE_COMMAND} -E copy
112+
# $<TARGET_FILE:Open3D::Open3D>
113+
# $<TARGET_FILE_DIR:${SHARED_LIB_NAME}>)
114+
# endif()
115+
# endif()
99116

100117
# Boost (header only) -----------------------------------------------------
101118
download_submodule_project(boost)
@@ -116,28 +133,30 @@ target_link_libraries(${SHARED_LIB_NAME} PUBLIC loguru::loguru)
116133
#--------------------------------------------------------------------------
117134
# executable for prototyping
118135
#--------------------------------------------------------------------------
119-
set(APP_NAME_EXE diffCheckApp)
136+
# set(APP_NAME_EXE diffCheckApp)
120137

121-
add_executable(${APP_NAME_EXE} src/diffCheckApp.cc)
138+
# add_executable(${APP_NAME_EXE} src/diffCheckApp.cc)
122139

123-
set_target_properties(${APP_NAME_EXE} PROPERTIES
124-
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
125-
)
140+
# set_target_properties(${APP_NAME_EXE} PROPERTIES
141+
# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
142+
# )
126143

127-
target_link_libraries(${APP_NAME_EXE} ${SHARED_LIB_NAME})
144+
# target_link_libraries(${APP_NAME_EXE} ${SHARED_LIB_NAME})
128145

129-
target_include_directories(${APP_NAME_EXE}
130-
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src
131-
)
146+
# target_include_directories(${APP_NAME_EXE}
147+
# PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src
148+
# )
132149

133150
#--------------------------------------------------------------------------
134151
# pybind11
135152
#--------------------------------------------------------------------------
153+
add_definitions(-D_GLIBCXX_DEBUG)
154+
136155
if (BUILD_PYTHON_MODULE)
137156
set(PYBINDMODULE_NAME diffcheck_bindings)
138-
set(PYPI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/gh/diffCheck/diffCheck)
139-
set(TARGET_DLL_PYPI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/gh/diffCheck/diffCheck/dlls)
140-
set(SPHINX_DOC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/doc)
157+
# set(PYPI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/gh/diffCheck/diffCheck)
158+
# set(TARGET_DLL_PYPI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/gh/diffCheck/diffCheck/dlls)
159+
# set(SPHINX_DOC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/doc)
141160

142161
download_submodule_project(pybind11)
143162
add_subdirectory(deps/pybind11)
@@ -151,27 +170,40 @@ if (BUILD_PYTHON_MODULE)
151170

152171
set(PYBIND11_PYTHON_VERSION 3.9.10)
153172

154-
pybind11_add_module(${PYBINDMODULE_NAME} src/diffCheckBindings.cc)
173+
pybind11_add_module(${PYBINDMODULE_NAME}
174+
MODULE
175+
src/diffCheckBindings.cc
176+
)
155177

156-
target_link_libraries(${PYBINDMODULE_NAME} PUBLIC ${SHARED_LIB_NAME})
157178
target_include_directories(${PYBINDMODULE_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
179+
target_link_libraries(${PYBINDMODULE_NAME} PUBLIC ${SHARED_LIB_NAME})
158180

159181
# copy the pyd file to the pypi directory
160-
add_custom_command(TARGET ${PYBINDMODULE_NAME} POST_BUILD
161-
COMMAND ${CMAKE_COMMAND} -E copy
162-
$<TARGET_FILE:${PYBINDMODULE_NAME}>
163-
${PYPI_DIR}
164-
)
165-
copy_dlls(${TARGET_DLL_PYPI_DIR} ${PYBINDMODULE_NAME})
166-
# copy the pyd/dlls for the sphinx documentation
167-
add_custom_command(TARGET ${PYBINDMODULE_NAME} POST_BUILD
168-
COMMAND ${CMAKE_COMMAND} -E copy
169-
$<TARGET_FILE:${PYBINDMODULE_NAME}>
170-
${SPHINX_DOC_DIR}
171-
)
172-
copy_dlls(${SPHINX_DOC_DIR} ${PYBINDMODULE_NAME})
182+
# add_custom_command(TARGET ${PYBINDMODULE_NAME} POST_BUILD
183+
# COMMAND ${CMAKE_COMMAND} -E copy
184+
# $<TARGET_FILE:${PYBINDMODULE_NAME}>
185+
# ${PYPI_DIR}
186+
# )
187+
# copy_dlls(${TARGET_DLL_PYPI_DIR} ${PYBINDMODULE_NAME})
188+
# # copy the pyd/dlls for the sphinx documentation
189+
# add_custom_command(TARGET ${PYBINDMODULE_NAME} POST_BUILD
190+
# COMMAND ${CMAKE_COMMAND} -E copy
191+
# $<TARGET_FILE:${PYBINDMODULE_NAME}>
192+
# ${SPHINX_DOC_DIR}
193+
# )
194+
# copy_dlls(${SPHINX_DOC_DIR} ${PYBINDMODULE_NAME})
173195
endif()
174196

197+
# install the diffCheck shared library to the system path
198+
install(TARGETS ${SHARED_LIB_NAME}
199+
LIBRARY DESTINATION lib
200+
ARCHIVE DESTINATION lib
201+
RUNTIME DESTINATION bin
202+
)
203+
204+
205+
206+
175207
#--------------------------------------------------------------------------
176208
# Tests
177209
#--------------------------------------------------------------------------

src/diffCheck/log.cc

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
namespace diffCheck
44
{
5-
void Log::Init()
6-
{
7-
int argc = 1;
8-
char* argv[] = { "loguru", nullptr };
9-
loguru::init(argc, argv);
10-
loguru::add_file("diffCheckEvery.log", loguru::Truncate, loguru::Verbosity_MAX);
11-
loguru::add_file("diffCheckErrors.log", loguru::Truncate, loguru::Verbosity_ERROR);
5+
// void Log::Init()
6+
// {
7+
// int argc = 1;
8+
// char* argv[] = { "loguru", nullptr };
9+
// loguru::init(argc, argv);
10+
// loguru::add_file("diffCheckEvery.log", loguru::Truncate, loguru::Verbosity_MAX);
11+
// loguru::add_file("diffCheckErrors.log", loguru::Truncate, loguru::Verbosity_ERROR);
1212

13-
loguru::g_stderr_verbosity = 1;
14-
loguru::g_colorlogtostderr = true;
15-
loguru::g_preamble = false;
16-
}
13+
// loguru::g_stderr_verbosity = 1;
14+
// loguru::g_colorlogtostderr = true;
15+
// loguru::g_preamble = false;
16+
// }
1717

18-
void Log::Shutdown()
19-
{
20-
loguru::shutdown();
21-
}
18+
// void Log::Shutdown()
19+
// {
20+
// loguru::shutdown();
21+
// }
2222
}

src/diffCheck/log.hh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,25 @@ namespace diffCheck
1111
~Log() { Shutdown(); }
1212

1313
private:
14-
void Init();
15-
void Shutdown();
14+
// void Init();
15+
// void Shutdown();
16+
void Init()
17+
{
18+
// int argc = 1;
19+
// char* argv[] = { "loguru", nullptr };
20+
// loguru::init(argc, argv);
21+
// loguru::add_file("diffCheckEvery.log", loguru::Truncate, loguru::Verbosity_MAX);
22+
// loguru::add_file("diffCheckErrors.log", loguru::Truncate, loguru::Verbosity_ERROR);
23+
24+
// loguru::g_stderr_verbosity = 1;
25+
// loguru::g_colorlogtostderr = true;
26+
// loguru::g_preamble = false;
27+
}
28+
29+
void Shutdown()
30+
{
31+
// loguru::shutdown();
32+
}
1633
};
1734
}
1835

src/diffCheck/segmentation/DFSegmentation.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace diffCheck::segmentation
3434
* @param associationThreshold the threshold to consider the points of a segment and a mesh face as associable. It is the ratio between the surface of the closest mesh triangle and the sum of the areas of the three triangles that form the rest of the pyramid described by the mesh triangle and the point we want to associate or not. The lower the number, the more strict the association will be and some poinnts on the mesh face might be wrongfully excluded.
3535
* @return std::shared_ptr<geometry::DFPointCloud> The unified segments
3636
*/
37-
static std::vector<std::shared_ptr<geometry::DFPointCloud>> DFSegmentation::AssociateClustersToMeshes(
37+
static std::vector<std::shared_ptr<geometry::DFPointCloud>> AssociateClustersToMeshes(
3838
bool isCylinder,
3939
std::vector<std::shared_ptr<geometry::DFMesh>> referenceMesh,
4040
std::vector<std::shared_ptr<geometry::DFPointCloud>> &clusters,
@@ -49,7 +49,7 @@ namespace diffCheck::segmentation
4949
* * @param angleThreshold the threshold to consider the a cluster as potential candidate for association. the value passed is the minimum sine of the angles. A value of 0 requires perfect alignment (angle = 0), while a value of 0.1 allows an angle of 5.7 degrees.
5050
* @param associationThreshold the threshold to consider the points of a segment and a mesh face as associable. It is the ratio between the surface of the closest mesh triangle and the sum of the areas of the three triangles that form the rest of the pyramid described by the mesh triangle and the point we want to associate or not. The lower the number, the more strict the association will be and some poinnts on the mesh face might be wrongfully excluded.
5151
*/
52-
static void DFSegmentation::CleanUnassociatedClusters(
52+
static void CleanUnassociatedClusters(
5353
bool isCylinder,
5454
std::vector<std::shared_ptr<geometry::DFPointCloud>> &unassociatedClusters,
5555
std::vector<std::shared_ptr<geometry::DFPointCloud>> &existingPointCloudSegments,

src/diffCheckApp.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
int main()
1414
{
15+
1516
std::cout << "Hello, World!" << std::endl;
1617
return 0;
1718
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#! python3
2+
3+
4+
5+
from ghpythonlib.componentbase import executingcomponent as component
6+
7+
8+
class DFPoseComparator(component):
9+
def RunScript(self,
10+
i_scan,
11+
i_assembly):
12+
# dump the xml
13+
o_xml = None
14+
xml: str = i_assembly.to_xml()
15+
if i_dump:
16+
i_assembly.dump_xml(xml, i_export_dir)
17+
o_xml = xml
18+
19+
return o_xml
11.5 KB
Loading

0 commit comments

Comments
 (0)