Skip to content

Commit 415127d

Browse files
Add color, image and material classes
1 parent 015a9eb commit 415127d

File tree

15 files changed

+3676
-0
lines changed

15 files changed

+3676
-0
lines changed

tesseract_common/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ find_package(Boost REQUIRED COMPONENTS system filesystem serialization)
1616
find_package(Eigen3 REQUIRED)
1717
find_package(TinyXML2 REQUIRED)
1818
find_package(yaml-cpp REQUIRED)
19+
find_package(FreeImage REQUIRED)
1920

2021
find_package(console_bridge REQUIRED)
2122
if(NOT TARGET console_bridge::console_bridge)
@@ -47,12 +48,18 @@ add_library(
4748
src/allowed_collision_matrix.cpp
4849
src/any_poly.cpp
4950
src/collision_margin_data.cpp
51+
src/color.cpp
5052
src/joint_state.cpp
5153
src/manipulator_info.cpp
54+
src/material.cpp
5255
src/kinematic_limits.cpp
5356
src/eigen_serialization.cpp
57+
src/image.cpp
5458
src/utils.cpp
5559
src/resource_locator.cpp
60+
src/shader_param.cpp
61+
src/shader_params.cpp
62+
src/shader_type.cpp
5663
src/types.cpp)
5764
target_link_libraries(
5865
${PROJECT_NAME}
@@ -64,6 +71,7 @@ target_link_libraries(
6471
Boost::filesystem
6572
Boost::serialization
6673
console_bridge::console_bridge
74+
${FreeImage_LIBRARIES}
6775
yaml-cpp)
6876
target_compile_options(${PROJECT_NAME} PUBLIC ${TESSERACT_COMPILE_OPTIONS_PUBLIC})
6977
target_compile_definitions(${PROJECT_NAME} PUBLIC ${TESSERACT_COMPILE_DEFINITIONS})
@@ -77,6 +85,8 @@ target_code_coverage(
7785
ENABLE ${TESSERACT_ENABLE_CODE_COVERAGE})
7886
target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
7987
"$<INSTALL_INTERFACE:include>")
88+
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
89+
${FreeImage_INCLUDE_DIRS})
8090

8191
configure_package(NAMESPACE tesseract TARGETS ${PROJECT_NAME})
8292

@@ -91,6 +101,8 @@ install(
91101

92102
install(
93103
FILES "${CMAKE_CURRENT_LIST_DIR}/cmake/tesseract_macros.cmake"
104+
"${CMAKE_CURRENT_LIST_DIR}/cmake/FindFreeImage.cmake"
105+
"${CMAKE_CURRENT_LIST_DIR}/cmake/FindPkgMacros.cmake"
94106
"${CMAKE_CURRENT_LIST_DIR}/cmake/FindTinyXML2.cmake"
95107
"${CMAKE_CURRENT_LIST_DIR}/cmake/Findtcmalloc.cmake"
96108
"${CMAKE_CURRENT_LIST_DIR}/cmake/Findtcmalloc_minimal.cmake"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#-------------------------------------------------------------------
2+
# This file is part of the CMake build system for OGRE
3+
# (Object-oriented Graphics Rendering Engine)
4+
# For the latest info, see http://www.ogre3d.org/
5+
#
6+
# The contents of this file are placed in the public domain. Feel
7+
# free to make use of it in any way you like.
8+
#-------------------------------------------------------------------
9+
10+
# - Try to find FreeImage
11+
# Once done, this will define
12+
#
13+
# FreeImage_FOUND - system has FreeImage
14+
# FreeImage_INCLUDE_DIRS - the FreeImage include directories
15+
# FreeImage_LIBRARIES - link these to use FreeImage
16+
17+
include(FindPkgMacros)
18+
findpkg_begin(FreeImage)
19+
20+
# Get path, convert backslashes as ${ENV_${var}}
21+
getenv_path(FREEIMAGE_HOME)
22+
23+
# construct search paths
24+
set(FreeImage_PREFIX_PATH ${FREEIMAGE_HOME} ${ENV_FREEIMAGE_HOME})
25+
create_search_paths(FreeImage "")
26+
# redo search if prefix path changed
27+
clear_if_changed(FreeImage_PREFIX_PATH
28+
FreeImage_LIBRARY_FWK
29+
FreeImage_LIBRARY_REL
30+
FreeImage_LIBRARY_DBG
31+
FreeImage_INCLUDE_DIR
32+
)
33+
34+
set(FreeImage_LIBRARY_NAMES freeimage freeimageLib FreeImage FreeImageLib)
35+
get_debug_names(FreeImage_LIBRARY_NAMES)
36+
37+
use_pkgconfig(FreeImage_PKGC freeimage)
38+
39+
findpkg_framework(FreeImage)
40+
41+
find_path(FreeImage_INCLUDE_DIR NAMES FreeImage.h HINTS ${FreeImage_INC_SEARCH_PATH} ${FreeImage_PKGC_INCLUDE_DIRS})
42+
43+
find_library(FreeImage_LIBRARY_REL NAMES ${FreeImage_LIBRARY_NAMES} HINTS ${FreeImage_LIB_SEARCH_PATH} ${FreeImage_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" Release RelWithDebInfo MinSizeRel)
44+
find_library(FreeImage_LIBRARY_DBG NAMES ${FreeImage_LIBRARY_NAMES_DBG} HINTS ${FreeImage_LIB_SEARCH_PATH} ${FreeImage_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" Debug)
45+
46+
make_library_set(FreeImage_LIBRARY)
47+
48+
findpkg_finish(FreeImage)
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
#-------------------------------------------------------------------
2+
# This file is part of the CMake build system for OGRE
3+
# (Object-oriented Graphics Rendering Engine)
4+
# For the latest info, see http://www.ogre3d.org/
5+
#
6+
# The contents of this file are placed in the public domain. Feel
7+
# free to make use of it in any way you like.
8+
#-------------------------------------------------------------------
9+
10+
##################################################################
11+
# Provides some common functionality for the FindPackage modules
12+
##################################################################
13+
14+
# Begin processing of package
15+
macro(findpkg_begin PREFIX)
16+
if (NOT ${PREFIX}_FIND_QUIETLY)
17+
message(STATUS "Looking for ${PREFIX}...")
18+
endif ()
19+
endmacro(findpkg_begin)
20+
21+
# Display a status message unless FIND_QUIETLY is set
22+
macro(pkg_message PREFIX)
23+
if (NOT ${PREFIX}_FIND_QUIETLY)
24+
message(STATUS ${ARGN})
25+
endif ()
26+
endmacro(pkg_message)
27+
28+
# Get environment variable, define it as ENV_$var and make sure backslashes are converted to forward slashes
29+
macro(getenv_path VAR)
30+
set(ENV_${VAR} $ENV{${VAR}})
31+
# replace won't work if var is blank
32+
if (ENV_${VAR})
33+
string( REGEX REPLACE "\\\\" "/" ENV_${VAR} ${ENV_${VAR}} )
34+
endif ()
35+
endmacro(getenv_path)
36+
37+
# Construct search paths for includes and libraries from a PREFIX_PATH
38+
macro(create_search_paths PREFIX PATH_SUFFIX)
39+
foreach(dir ${${PREFIX}_PREFIX_PATH})
40+
set(${PREFIX}_INC_SEARCH_PATH ${${PREFIX}_INC_SEARCH_PATH}
41+
${dir}/include ${dir}/Include ${dir}/include/${PREFIX}${PATH_SUFFIX} ${dir}/Headers)
42+
set(${PREFIX}_LIB_SEARCH_PATH ${${PREFIX}_LIB_SEARCH_PATH}
43+
${dir}/lib ${dir}/Lib ${dir}/lib/${PREFIX}${PATH_SUFFIX} ${dir}/Libs)
44+
set(${PREFIX}_BIN_SEARCH_PATH ${${PREFIX}_BIN_SEARCH_PATH}
45+
${dir}/bin)
46+
endforeach(dir)
47+
if(ANDROID)
48+
set(${PREFIX}_LIB_SEARCH_PATH ${${PREFIX}_LIB_SEARCH_PATH} ${OGRE_DEPENDENCIES_DIR}/lib/${ANDROID_ABI})
49+
endif()
50+
set(${PREFIX}_FRAMEWORK_SEARCH_PATH ${${PREFIX}_PREFIX_PATH})
51+
endmacro(create_search_paths)
52+
53+
# clear cache variables if a certain variable changed
54+
macro(clear_if_changed TESTVAR)
55+
# test against internal check variable
56+
# HACK: Apparently, adding a variable to the cache cleans up the list
57+
# a bit. We need to also remove any empty strings from the list, but
58+
# at the same time ensure that we are actually dealing with a list.
59+
list(APPEND ${TESTVAR} "")
60+
list(REMOVE_ITEM ${TESTVAR} "")
61+
if (NOT "${${TESTVAR}}" STREQUAL "${${TESTVAR}_INT_CHECK}")
62+
message(STATUS "${TESTVAR} changed.")
63+
foreach(var ${ARGN})
64+
set(${var} "NOTFOUND" CACHE STRING "x" FORCE)
65+
endforeach(var)
66+
endif ()
67+
set(${TESTVAR}_INT_CHECK ${${TESTVAR}} CACHE INTERNAL "x" FORCE)
68+
endmacro(clear_if_changed)
69+
70+
# Try to get some hints from pkg-config, if available
71+
macro(use_pkgconfig PREFIX PKGNAME)
72+
if(NOT ANDROID)
73+
find_package(PkgConfig)
74+
if (PKG_CONFIG_FOUND)
75+
pkg_check_modules(${PREFIX} ${PKGNAME})
76+
endif ()
77+
endif()
78+
endmacro (use_pkgconfig)
79+
80+
# Couple a set of release AND debug libraries (or frameworks)
81+
macro(make_library_set PREFIX)
82+
if (${PREFIX}_FWK)
83+
set(${PREFIX} ${${PREFIX}_FWK})
84+
elseif (${PREFIX}_REL AND ${PREFIX}_DBG)
85+
set(${PREFIX} optimized ${${PREFIX}_REL} debug ${${PREFIX}_DBG})
86+
elseif (${PREFIX}_REL)
87+
set(${PREFIX} ${${PREFIX}_REL})
88+
elseif (${PREFIX}_DBG)
89+
set(${PREFIX} ${${PREFIX}_DBG})
90+
endif ()
91+
endmacro(make_library_set)
92+
93+
# Generate debug names from given release names
94+
macro(get_debug_names PREFIX)
95+
foreach(i ${${PREFIX}})
96+
set(${PREFIX}_DBG ${${PREFIX}_DBG} ${i}d ${i}D ${i}_d ${i}_D ${i}_debug ${i})
97+
endforeach(i)
98+
endmacro(get_debug_names)
99+
100+
# Add the parent dir from DIR to VAR
101+
macro(add_parent_dir VAR DIR)
102+
get_filename_component(${DIR}_TEMP "${${DIR}}/.." ABSOLUTE)
103+
set(${VAR} ${${VAR}} ${${DIR}_TEMP})
104+
endmacro(add_parent_dir)
105+
106+
# Do the final processing for the package find.
107+
macro(findpkg_finish PREFIX)
108+
# skip if already processed during this run
109+
if (NOT ${PREFIX}_FOUND)
110+
if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY)
111+
set(${PREFIX}_FOUND TRUE)
112+
set(${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIR})
113+
set(${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARY})
114+
if (NOT ${PREFIX}_FIND_QUIETLY)
115+
message(STATUS "Found ${PREFIX}: ${${PREFIX}_LIBRARIES}")
116+
endif ()
117+
else ()
118+
if (NOT ${PREFIX}_FIND_QUIETLY)
119+
message(STATUS "Could not locate ${PREFIX}")
120+
endif ()
121+
if (${PREFIX}_FIND_REQUIRED)
122+
message(FATAL_ERROR "Required library ${PREFIX} not found! Install the library (including dev packages) and try again. If the library is already installed, set the missing variables manually in cmake.")
123+
endif ()
124+
endif ()
125+
126+
mark_as_advanced(${PREFIX}_INCLUDE_DIR ${PREFIX}_LIBRARY ${PREFIX}_LIBRARY_REL ${PREFIX}_LIBRARY_DBG ${PREFIX}_LIBRARY_FWK)
127+
endif ()
128+
endmacro(findpkg_finish)
129+
130+
131+
# Slightly customised framework finder
132+
macro(findpkg_framework fwk)
133+
if(APPLE)
134+
set(${fwk}_FRAMEWORK_PATH
135+
${${fwk}_FRAMEWORK_SEARCH_PATH}
136+
${CMAKE_FRAMEWORK_PATH}
137+
~/Library/Frameworks
138+
/Library/Frameworks
139+
/System/Library/Frameworks
140+
/Network/Library/Frameworks
141+
${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/Release
142+
${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/Debug
143+
)
144+
# These could be arrays of paths, add each individually to the search paths
145+
foreach(i ${OGRE_PREFIX_PATH})
146+
set(${fwk}_FRAMEWORK_PATH ${${fwk}_FRAMEWORK_PATH} ${i}/lib/macosx/Release ${i}/lib/macosx/Debug)
147+
endforeach(i)
148+
149+
foreach(i ${OGRE_PREFIX_BUILD})
150+
set(${fwk}_FRAMEWORK_PATH ${${fwk}_FRAMEWORK_PATH} ${i}/lib/macosx/Release ${i}/lib/macosx/Debug)
151+
endforeach(i)
152+
153+
foreach(dir ${${fwk}_FRAMEWORK_PATH})
154+
set(fwkpath ${dir}/${fwk}.framework)
155+
if(EXISTS ${fwkpath})
156+
set(${fwk}_FRAMEWORK_INCLUDES ${${fwk}_FRAMEWORK_INCLUDES}
157+
${fwkpath}/Headers ${fwkpath}/PrivateHeaders)
158+
set(${fwk}_FRAMEWORK_PATH ${dir})
159+
if (NOT ${fwk}_LIBRARY_FWK)
160+
set(${fwk}_LIBRARY_FWK "-framework ${fwk}")
161+
endif ()
162+
endif(EXISTS ${fwkpath})
163+
endforeach(dir)
164+
endif(APPLE)
165+
endmacro(findpkg_framework)

0 commit comments

Comments
 (0)