Skip to content

Commit 83d3ba5

Browse files
larshgmvieth
andauthored
Changes to tools (PointCloudLibrary#5605)
* Move IO tools to tools folder. * Made all dependencies optional and build tools if requirements are met. * Fix opnni_viewer_simple * Satisfy clang-tidy * Make io hard-dependency. * Link pcl_common to pcl_io_ply. * Fix includes from pcl_common. * Remove check for pcl_io target. Move tools under if target pcl_recognition. Move tools under other if, having nested if instead of multiple conditions in ifs. * More reorganizing due to dependencies. * Fixup remove boost. * Fix missing TARGET keyword Co-authored-by: Markus Vieth <[email protected]> --------- Co-authored-by: Markus Vieth <[email protected]>
1 parent ad56383 commit 83d3ba5

18 files changed

+288
-254
lines changed

common/CMakeLists.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,13 @@ set(kissfft_srcs
172172
)
173173

174174
set(LIB_NAME "pcl_${SUBSYS_NAME}")
175-
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
176175
PCL_ADD_LIBRARY(${LIB_NAME} COMPONENT ${SUBSYS_NAME} SOURCES ${srcs} ${kissfft_srcs} ${incs} ${common_incs} ${impl_incs} ${tools_incs} ${kissfft_incs} ${common_incs_impl} ${range_image_incs} ${range_image_incs_impl})
177176

177+
target_include_directories(${LIB_NAME} PUBLIC
178+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
179+
$<INSTALL_INTERFACE:include>
180+
)
181+
178182
target_link_libraries(${LIB_NAME} Boost::boost)
179183

180184
if(MSVC AND NOT (MSVC_VERSION LESS 1915))

io/CMakeLists.txt

+1-5
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ if(MINGW)
211211
endif()
212212
PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/ply" ${PLY_INCLUDES})
213213
target_include_directories(pcl_io_ply PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
214-
target_link_libraries(pcl_io_ply Boost::boost)
214+
target_link_libraries(pcl_io_ply pcl_common Boost::boost)
215215

216216
set(srcs
217217
src/debayer.cpp
@@ -440,7 +440,3 @@ PCL_ADD_INCLUDES("${SUBSYS_NAME}" compression ${compression_incs})
440440
PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/openni_camera" ${OPENNI_INCLUDES})
441441
PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/openni2" ${OPENNI2_INCLUDES})
442442
PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/impl" ${impl_incs})
443-
444-
if(BUILD_tools)
445-
add_subdirectory(tools)
446-
endif()

io/tools/CMakeLists.txt

-28
This file was deleted.

io/tools/ply/CMakeLists.txt

-11
This file was deleted.

tools/CMakeLists.txt

+264-197
Large diffs are not rendered by default.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tools/openni_viewer_simple.cpp

+18-12
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ class SimpleOpenNIViewer
121121
void
122122
keyboard_callback (const pcl::visualization::KeyboardEvent& event, void* cookie)
123123
{
124-
string* message = (string*)cookie;
124+
auto message = static_cast<std::string*>(cookie);
125125
std::cout << (*message) << " :: ";
126126
if (event.getKeyCode())
127-
std::cout << "the key \'" << event.getKeyCode() << "\' (" << (int)event.getKeyCode() << ") was";
127+
std::cout << "the key \'" << event.getKeyCode() << "\' (" << static_cast<int>(event.getKeyCode()) << ") was";
128128
else
129129
std::cout << "the special key \'" << event.getKeySym() << "\' was";
130130
if (event.keyDown())
@@ -135,7 +135,7 @@ class SimpleOpenNIViewer
135135

136136
void mouse_callback (const pcl::visualization::MouseEvent& mouse_event, void* cookie)
137137
{
138-
string* message = (string*) cookie;
138+
auto message = static_cast<std::string*>(cookie);
139139
if (mouse_event.getType() == pcl::visualization::MouseEvent::MouseButtonPress && mouse_event.getButton() == pcl::visualization::MouseEvent::LeftButton)
140140
{
141141
std::cout << (*message) << " :: " << mouse_event.getX () << " , " << mouse_event.getY () << std::endl;
@@ -167,8 +167,10 @@ class SimpleOpenNIViewer
167167

168168
std::string mouseMsg3D("Mouse coordinates in PCL Visualizer");
169169
std::string keyMsg3D("Key event for PCL Visualizer");
170-
cloud_viewer_.registerMouseCallback (&SimpleOpenNIViewer::mouse_callback, *this, (void*)(&mouseMsg3D));
171-
cloud_viewer_.registerKeyboardCallback(&SimpleOpenNIViewer::keyboard_callback, *this, (void*)(&keyMsg3D));
170+
cloud_viewer_.registerMouseCallback(
171+
&SimpleOpenNIViewer::mouse_callback, *this, static_cast<void*>(&mouseMsg3D));
172+
cloud_viewer_.registerKeyboardCallback(
173+
&SimpleOpenNIViewer::keyboard_callback, *this, static_cast<void*>(&keyMsg3D));
172174
std::function<void (const CloudConstPtr&)> cloud_cb = [this] (const CloudConstPtr& cloud) { cloud_callback (cloud); };
173175
boost::signals2::connection cloud_connection = grabber_.registerCallback (cloud_cb);
174176

@@ -177,12 +179,16 @@ class SimpleOpenNIViewer
177179
{
178180
std::string mouseMsg2D("Mouse coordinates in image viewer");
179181
std::string keyMsg2D("Key event for image viewer");
180-
image_viewer_.registerMouseCallback (&SimpleOpenNIViewer::mouse_callback, *this, (void*)(&mouseMsg2D));
181-
image_viewer_.registerKeyboardCallback(&SimpleOpenNIViewer::keyboard_callback, *this, (void*)(&keyMsg2D));
182+
image_viewer_.registerMouseCallback(&SimpleOpenNIViewer::mouse_callback,
183+
*this,
184+
static_cast<void*>(&mouseMsg2D));
185+
image_viewer_.registerKeyboardCallback(&SimpleOpenNIViewer::keyboard_callback,
186+
*this,
187+
static_cast<void*>(&keyMsg2D));
182188
std::function<void (const openni_wrapper::Image::Ptr&)> image_cb = [this] (const openni_wrapper::Image::Ptr& img) { image_callback (img); };
183189
image_connection = grabber_.registerCallback (image_cb);
184190
}
185-
unsigned char* rgb_data = 0;
191+
unsigned char* rgb_data = nullptr;
186192
unsigned rgb_data_size = 0;
187193

188194
grabber_.start ();
@@ -271,7 +277,7 @@ usage(char ** argv)
271277
int
272278
main(int argc, char ** argv)
273279
{
274-
std::string device_id("");
280+
std::string device_id;
275281
pcl::OpenNIGrabber::Mode depth_mode = pcl::OpenNIGrabber::OpenNI_Default_Mode;
276282
pcl::OpenNIGrabber::Mode image_mode = pcl::OpenNIGrabber::OpenNI_Default_Mode;
277283
bool xyz = false;
@@ -315,7 +321,7 @@ main(int argc, char ** argv)
315321
for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx)
316322
{
317323
std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName(deviceIdx) << ", product: " << driver.getProductName(deviceIdx)
318-
<< ", connected: " << (int) driver.getBus(deviceIdx) << " @ " << (int) driver.getAddress(deviceIdx) << ", serial number: \'" << driver.getSerialNumber(deviceIdx) << "\'" << std::endl;
324+
<< ", connected: " << static_cast<int>(driver.getBus(deviceIdx)) << " @ " << static_cast<int>(driver.getAddress(deviceIdx)) << ", serial number: \'" << driver.getSerialNumber(deviceIdx) << "\'" << std::endl;
319325
}
320326

321327
}
@@ -336,10 +342,10 @@ main(int argc, char ** argv)
336342

337343
unsigned mode;
338344
if (pcl::console::parse(argc, argv, "-depthmode", mode) != -1)
339-
depth_mode = (pcl::OpenNIGrabber::Mode) mode;
345+
depth_mode = static_cast<pcl::OpenNIGrabber::Mode>(mode);
340346

341347
if (pcl::console::parse(argc, argv, "-imagemode", mode) != -1)
342-
image_mode = (pcl::OpenNIGrabber::Mode) mode;
348+
image_mode = static_cast<pcl::OpenNIGrabber::Mode>(mode);
343349

344350
if (pcl::console::find_argument(argc, argv, "-xyz") != -1)
345351
xyz = true;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)