Skip to content

Commit 235ecf8

Browse files
Add color, image and material classes
1 parent 015a9eb commit 235ecf8

File tree

15 files changed

+3716
-0
lines changed

15 files changed

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

0 commit comments

Comments
 (0)