Skip to content

Commit d7317bb

Browse files
committed
Add instantiations for ICP and TransformationEstimationSVD
Add explicit instantiations in the .cpp files, for very commonly used point types (while building pcl_registration). When using ICP or TransformationEstimationSVD in other files, the `extern template class ...` statements in the .h files tell the compiler to not instantiate the templates, and to use the previous instantiations instead (from pcl_registration). This decreases the compilation time for user code, and also for e.g. pcl tools and pcl apps (the pcl_icp tool for example compiles in 10s now vs 13s before). The compilation time of PCL as a whole decreases slightly (1.5 percent less in one configuration with clang).
1 parent e2656ed commit d7317bb

File tree

6 files changed

+45
-3
lines changed

6 files changed

+45
-3
lines changed

apps/3d_rec_framework/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ PCL_ADD_INCLUDES("${SUBSUBSYS_NAME}" "${SUBSYS_NAME}/${SUBSUBSYS_NAME}/pipeline/
9090

9191
set(LIB_NAME "pcl_${SUBSUBSYS_NAME}")
9292
PCL_ADD_LIBRARY(${LIB_NAME} COMPONENT ${SUBSUBSYS_NAME} SOURCES ${srcs} ${impl_incs_pipeline} ${incs_utils} ${incs_fw} ${incs_fw_global} ${incs_fw_local} ${incc_tools_framework} ${incs_pipelines} ${incs_pc_source})
93-
target_link_libraries("${LIB_NAME}" pcl_apps pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_surface pcl_features pcl_sample_consensus pcl_search)
93+
target_link_libraries("${LIB_NAME}" pcl_apps pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_surface pcl_features pcl_sample_consensus pcl_search pcl_registration)
9494

9595
if(WITH_OPENNI)
9696
target_link_libraries("${LIB_NAME}" ${OPENNI_LIBRARIES})

apps/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ if(VTK_FOUND)
9292
src/manual_registration/pcl_viewer_dialog.ui
9393
BUNDLE)
9494

95-
target_link_libraries(pcl_manual_registration pcl_common pcl_io pcl_visualization pcl_segmentation pcl_features pcl_surface ${QTX}::Widgets)
95+
target_link_libraries(pcl_manual_registration pcl_common pcl_io pcl_visualization pcl_segmentation pcl_features pcl_surface pcl_registration ${QTX}::Widgets)
9696

9797
PCL_ADD_EXECUTABLE(pcl_pcd_video_player
9898
COMPONENT

registration/include/pcl/registration/icp.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
#include <pcl/registration/transformation_estimation_point_to_plane_lls.h>
4848
#include <pcl/registration/transformation_estimation_svd.h>
4949
#include <pcl/registration/transformation_estimation_symmetric_point_to_plane_lls.h>
50-
#include <pcl/memory.h> // for dynamic_pointer_cast, pcl::make_shared, shared_ptr
50+
#include <pcl/memory.h> // for dynamic_pointer_cast, pcl::make_shared, shared_ptr
51+
#include <pcl/pcl_config.h> // for PCL_NO_PRECOMPILE
5152

5253
namespace pcl {
5354
/** \brief @b IterativeClosestPoint provides a base implementation of the Iterative
@@ -447,3 +448,9 @@ class IterativeClosestPointWithNormals
447448
} // namespace pcl
448449

449450
#include <pcl/registration/impl/icp.hpp>
451+
452+
#if !defined(PCL_NO_PRECOMPILE) && !defined(PCL_REGISTRATION_ICP_CPP_)
453+
extern template class pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ>;
454+
extern template class pcl::IterativeClosestPoint<pcl::PointXYZI, pcl::PointXYZI>;
455+
extern template class pcl::IterativeClosestPoint<pcl::PointXYZRGB, pcl::PointXYZRGB>;
456+
#endif // PCL_NO_PRECOMPILE

registration/include/pcl/registration/transformation_estimation_svd.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
#include <pcl/registration/transformation_estimation.h>
4444
#include <pcl/cloud_iterator.h>
45+
#include <pcl/pcl_config.h> // for PCL_NO_PRECOMPILE
4546

4647
namespace pcl {
4748
namespace registration {
@@ -154,3 +155,13 @@ class TransformationEstimationSVD
154155
} // namespace pcl
155156

156157
#include <pcl/registration/impl/transformation_estimation_svd.hpp>
158+
159+
#if !defined(PCL_NO_PRECOMPILE) && \
160+
!defined(PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_SVD_CPP_)
161+
extern template class pcl::registration::TransformationEstimationSVD<pcl::PointXYZ,
162+
pcl::PointXYZ>;
163+
extern template class pcl::registration::TransformationEstimationSVD<pcl::PointXYZI,
164+
pcl::PointXYZI>;
165+
extern template class pcl::registration::TransformationEstimationSVD<pcl::PointXYZRGB,
166+
pcl::PointXYZRGB>;
167+
#endif // PCL_NO_PRECOMPILE

registration/src/icp.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,15 @@
3737
*
3838
*/
3939

40+
#define PCL_REGISTRATION_ICP_CPP_
4041
#include <pcl/registration/icp.h>
42+
#include <pcl/pcl_config.h> // for PCL_NO_PRECOMPILE
43+
44+
#ifndef PCL_NO_PRECOMPILE
45+
#include <pcl/pcl_exports.h> // for PCL_EXPORTS
46+
#include <pcl/point_types.h>
47+
template class PCL_EXPORTS pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ>;
48+
template class PCL_EXPORTS pcl::IterativeClosestPoint<pcl::PointXYZI, pcl::PointXYZI>;
49+
template class PCL_EXPORTS
50+
pcl::IterativeClosestPoint<pcl::PointXYZRGB, pcl::PointXYZRGB>;
51+
#endif // PCL_NO_PRECOMPILE

registration/src/transformation_estimation_svd.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,17 @@
3636
*
3737
*/
3838

39+
#define PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_SVD_CPP_
3940
#include <pcl/registration/transformation_estimation_svd.h>
41+
#include <pcl/pcl_config.h> // for PCL_NO_PRECOMPILE
42+
43+
#ifndef PCL_NO_PRECOMPILE
44+
#include <pcl/pcl_exports.h> // for PCL_EXPORTS
45+
#include <pcl/point_types.h>
46+
template class PCL_EXPORTS
47+
pcl::registration::TransformationEstimationSVD<pcl::PointXYZ, pcl::PointXYZ>;
48+
template class PCL_EXPORTS
49+
pcl::registration::TransformationEstimationSVD<pcl::PointXYZI, pcl::PointXYZI>;
50+
template class PCL_EXPORTS
51+
pcl::registration::TransformationEstimationSVD<pcl::PointXYZRGB, pcl::PointXYZRGB>;
52+
#endif // PCL_NO_PRECOMPILE

0 commit comments

Comments
 (0)