diff --git a/.gitignore b/.gitignore index 85152fb..da016a7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ *.cur_trans build .ipynb_checkpoints/ +pointmatcher/pm_export.h \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 819a834..d72850a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,7 +233,7 @@ else() #get_property(yaml-cpp-pm_INCLUDE TARGET yaml-cpp-pm PROPERTY INCLUDE_DIRECTORIES) #include_directories(${yaml-cpp-pm_INCLUDE}) - list(APPEND EXTERNAL_LIBS $) + list(APPEND EXTERNAL_LIBS $) list(APPEND EXTRA_DEPS yaml-cpp-pm) set(yamlcpp_FOUND) @@ -291,6 +291,8 @@ else () set (CMAKE_CXX_STANDARD 11) endif () +option(BUILD_SHARED_LIBS "Set to ON to build shared libraries" OFF) + # SOURCE # Pointmatcher lib and install @@ -363,12 +365,18 @@ set(POINTMATCHER_SRC file(GLOB_RECURSE POINTMATCHER_HEADERS "pointmatcher/*.h") - # In CMake >=3.4 we can easily build shared libraries in Mac and Windows. # No need to distinguish between operating systems while building targets add_library(pointmatcher ${POINTMATCHER_SRC} ${POINTMATCHER_HEADERS} ) +include(GenerateExportHeader) +generate_export_header(pointmatcher + BASE_NAME PM + EXPORT_FILE_NAME "${CMAKE_CURRENT_SOURCE_DIR}/pointmatcher/pm_export.h" + DEFINE_NO_DEPRECATED +) + target_include_directories(pointmatcher PUBLIC $ $ @@ -417,6 +425,7 @@ install(FILES pointmatcher/Timer.h pointmatcher/Functions.h pointmatcher/IO.h + pointmatcher/pm_export.h DESTINATION ${INSTALL_INCLUDE_DIR}/pointmatcher ) @@ -515,7 +524,7 @@ add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS pointmatcher) get_property(CONF_INCLUDE_DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) # Create variable with the library location -set(POINTMATCHER_LIB $) +set(POINTMATCHER_LIB $) # Configure config file for local build tree configure_file(libpointmatcherConfig.cmake.in diff --git a/pointmatcher/Bibliography.h b/pointmatcher/Bibliography.h index 17a353d..c86def5 100644 --- a/pointmatcher/Bibliography.h +++ b/pointmatcher/Bibliography.h @@ -40,6 +40,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include "pm_export.h" + namespace PointMatcherSupport { typedef std::vector StringVector; @@ -48,7 +50,7 @@ namespace PointMatcherSupport typedef StringMapMap Bibliography; typedef std::map BibIndices; - struct CurrentBibliography + struct PM_EXPORT CurrentBibliography { enum Mode { @@ -68,7 +70,7 @@ namespace PointMatcherSupport void dumpBibtex(std::ostream& os) const; }; - std::string getAndReplaceBibEntries(const std::string&, CurrentBibliography& curBib); + PM_EXPORT std::string getAndReplaceBibEntries(const std::string&, CurrentBibliography& curBib); }; // PointMatcherSupport diff --git a/pointmatcher/DeprecationWarnings.h b/pointmatcher/DeprecationWarnings.h index b1ca8ec..dc84582 100644 --- a/pointmatcher/DeprecationWarnings.h +++ b/pointmatcher/DeprecationWarnings.h @@ -31,7 +31,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef __POINTMATCHER_DEPRECATION_WARNINGS_H #define __POINTMATCHER_DEPRECATION_WARNINGS_H - #if __cplusplus >= 201402L #define PM_DEPRECATED(msg) [[deprecated(msg)]] #define PM_DEPRECATION_SUPPORTED diff --git a/pointmatcher/IO.cpp b/pointmatcher/IO.cpp index c4288c9..8722747 100644 --- a/pointmatcher/IO.cpp +++ b/pointmatcher/IO.cpp @@ -51,7 +51,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "boost/lexical_cast.hpp" #include "boost/foreach.hpp" -#ifdef WIN32 +#ifdef _WIN32 #define strtok_r strtok_s #endif // WIN32 @@ -359,7 +359,9 @@ void PointMatcherSupport::validateFile(const std::string& fileName) ifstream ifs(fileName.c_str()); if (!ifs.good() || !boost::filesystem::is_regular_file(fullPath)) #if BOOST_FILESYSTEM_VERSION >= 3 - #if BOOST_VERSION >= 105000 + #if BOOST_VERSION >= 109000 + throw runtime_error(string("Cannot open file ") + boost::filesystem::absolute(fullPath).generic_string()); + #elif BOOST_VERSION >= 105000 throw runtime_error(string("Cannot open file ") + boost::filesystem::complete(fullPath).generic_string()); #else throw runtime_error(string("Cannot open file ") + boost::filesystem3::complete(fullPath).generic_string()); @@ -375,7 +377,11 @@ template typename PointMatcher::DataPoints PointMatcher::DataPoints::load(const std::string& fileName) { const boost::filesystem::path path(fileName); +#if BOOST_VERSION >= 109000 + const string ext = path.extension().string(); +#else const string& ext(boost::filesystem::extension(path)); +#endif if (boost::iequals(ext, ".vtk")) return PointMatcherIO::loadVTK(fileName); else if (boost::iequals(ext, ".csv")) @@ -809,7 +815,11 @@ template void PointMatcher::DataPoints::save(const std::string& fileName, bool binary) const { const boost::filesystem::path path(fileName); +#if BOOST_VERSION >= 109000 + const string ext = path.extension().string(); +#else const string& ext(boost::filesystem::extension(path)); +#endif if (boost::iequals(ext, ".vtk")) return PointMatcherIO::saveVTK(*this, fileName, binary); diff --git a/pointmatcher/IO.h b/pointmatcher/IO.h index 162dc21..8a0cefa 100644 --- a/pointmatcher/IO.h +++ b/pointmatcher/IO.h @@ -58,7 +58,7 @@ struct PointMatcherIO //! ex: nx, ny, nz are associated with (0,normals) (1,normals) (2,normals) respectively typedef std::map SublabelAssociationMap; - static std::string getColLabel(const Label& label, const int row); //!< convert a descriptor label to an appropriate sub-label + PM_EXPORT static std::string getColLabel(const Label& label, const int row); //!< convert a descriptor label to an appropriate sub-label //! Type of information in a DataPoints. Each type is stored in its own dense matrix. enum PMPropTypes @@ -70,7 +70,7 @@ struct PointMatcherIO }; //! Structure containing all information required to map external information to PointMatcher internal representation - struct SupportedLabel + struct PM_EXPORT SupportedLabel { std::string internalName; //!< name used in PointMatcher std::string externalName; //!< name used in external format @@ -84,7 +84,7 @@ struct PointMatcherIO typedef std::vector SupportedLabels; //! Helper structure designed to parse file headers - struct GenericInputHeader + struct PM_EXPORT GenericInputHeader { std::string name; //!< name found in the file unsigned int matrixRowId; //!< on which row the information will be loaded @@ -159,7 +159,7 @@ struct PointMatcherIO } //! Generate a vector of Labels by checking for collision is the same name is reused. - class LabelGenerator + class PM_EXPORT LabelGenerator { Labels labels; //!< vector of labels used to cumulat information @@ -180,11 +180,11 @@ struct PointMatcherIO //static PMPropTypes getPMType(const std::string& externalName); //! Return the type of information specific to a DataPoints based on a sulabel name // CSV - static DataPoints loadCSV(const std::string& fileName); - static DataPoints loadCSV(std::istream& is); + PM_EXPORT static DataPoints loadCSV(const std::string& fileName); + PM_EXPORT static DataPoints loadCSV(std::istream& is); - static void saveCSV(const DataPoints& data, const std::string& fileName); - static void saveCSV(const DataPoints& data, std::ostream& os); + PM_EXPORT static void saveCSV(const DataPoints& data, const std::string& fileName); + PM_EXPORT static void saveCSV(const DataPoints& data, std::ostream& os); // VTK //! Enumeration of legacy VTK data types that can be parsed @@ -209,25 +209,25 @@ struct PointMatcherIO }; - static DataPoints loadVTK(const std::string& fileName); - static DataPoints loadVTK(std::istream& is); + PM_EXPORT static DataPoints loadVTK(const std::string& fileName); + PM_EXPORT static DataPoints loadVTK(std::istream& is); - static void saveVTK(const DataPoints& data, const std::string& fileName, bool binary = false); + PM_EXPORT static void saveVTK(const DataPoints& data, const std::string& fileName, bool binary = false); // PLY - static DataPoints loadPLY(const std::string& fileName); - static DataPoints loadPLY(std::istream& is); + PM_EXPORT static DataPoints loadPLY(const std::string& fileName); + PM_EXPORT static DataPoints loadPLY(std::istream& is); - static void savePLY(const DataPoints& data, const std::string& fileName); //!< save datapoints to PLY point cloud format + PM_EXPORT static void savePLY(const DataPoints& data, const std::string& fileName); //!< save datapoints to PLY point cloud format // PCD - static DataPoints loadPCD(const std::string& fileName); - static DataPoints loadPCD(std::istream& is); + PM_EXPORT static DataPoints loadPCD(const std::string& fileName); + PM_EXPORT static DataPoints loadPCD(std::istream& is); - static void savePCD(const DataPoints& data, const std::string& fileName); //!< save datapoints to PCD point cloud format + PM_EXPORT static void savePCD(const DataPoints& data, const std::string& fileName); //!< save datapoints to PCD point cloud format //! Information to exploit a reading from a file using this library. Fields might be left blank if unused. - struct FileInfo + struct PM_EXPORT FileInfo { typedef Eigen::Matrix Vector3; //!< alias @@ -242,7 +242,7 @@ struct PointMatcherIO }; //! A vector of file info, to be used in batch processing - struct FileInfoVector: public std::vector + struct PM_EXPORT FileInfoVector: public std::vector { FileInfoVector(); FileInfoVector(const std::string& fileName, std::string dataPath = "", std::string configPath = ""); @@ -264,7 +264,7 @@ struct PointMatcherIO static bool plyPropTypeValid (const std::string& type); //! Interface for PLY property - struct PLYProperty + struct PM_EXPORT PLYProperty { //PLY information: std::string name; //!< name of PLY property @@ -299,7 +299,7 @@ struct PointMatcherIO typedef typename PLYProperties::iterator it_PLYProp; //! Interface for all PLY elements. - class PLYElement + class PM_EXPORT PLYElement { public: std::string name; //!< name identifying the PLY element @@ -331,7 +331,7 @@ struct PointMatcherIO //! Implementation of PLY vertex element - class PLYVertex : public PLYElement + class PM_EXPORT PLYVertex : public PLYElement { public: //! Constructor @@ -346,7 +346,7 @@ struct PointMatcherIO }; //! Factory for PLY elements - class PLYElementF + class PM_EXPORT PLYElementF { enum ElementTypes { diff --git a/pointmatcher/Parametrizable.h b/pointmatcher/Parametrizable.h index 318e7f1..edc1355 100644 --- a/pointmatcher/Parametrizable.h +++ b/pointmatcher/Parametrizable.h @@ -46,6 +46,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define BOOST_ASSIGN_MAX_PARAMS 6 #include +#include "pm_export.h" namespace PointMatcherSupport { @@ -95,7 +96,7 @@ namespace PointMatcherSupport } //! The superclass of classes that are constructed using generic parameters. This class provides the parameter storage and fetching mechanism - struct Parametrizable + struct PM_EXPORT Parametrizable { //! An exception thrown when one tries to fetch the value of an unexisting parameter struct InvalidParameter: std::runtime_error @@ -114,7 +115,7 @@ namespace PointMatcherSupport } //! The documentation of a parameter - struct ParameterDoc + struct PM_EXPORT ParameterDoc { std::string name; //!< name std::string doc; //!< short documentation @@ -173,7 +174,7 @@ namespace PointMatcherSupport friend std::ostream& operator<< (std::ostream& o, const Parametrizable& p); }; - std::ostream& operator<< (std::ostream& o, const Parametrizable::ParametersDoc& p); + PM_EXPORT std::ostream& operator<< (std::ostream& o, const Parametrizable::ParametersDoc& p); } // namespace PointMatcherSupport #endif // __POINTMATCHER_PARAMETRIZABLE_H diff --git a/pointmatcher/PointMatcher.h b/pointmatcher/PointMatcher.h index f26aa2c..435a464 100644 --- a/pointmatcher/PointMatcher.h +++ b/pointmatcher/PointMatcher.h @@ -101,7 +101,7 @@ namespace PointMatcherSupport //! The logger interface, used to output warnings and informations - struct Logger: public Parametrizable + struct PM_EXPORT Logger: public Parametrizable { Logger(); Logger(const std::string& className, const ParametersDoc paramsDoc, const Parameters& params); @@ -127,7 +127,7 @@ namespace PointMatcherSupport //! Functions and classes that are dependant on scalar type are defined in this templatized class template -struct PointMatcher +struct PM_EXPORT PointMatcher { // --------------------------------- // macros for constants @@ -145,7 +145,7 @@ struct PointMatcher //TODO: gather exceptions here and in Exceptions.cpp //! Point matcher did not converge - struct ConvergenceError: std::runtime_error + struct PM_EXPORT ConvergenceError: std::runtime_error { ConvergenceError(const std::string& reason); }; @@ -204,7 +204,7 @@ struct PointMatcher Moreover, the position of the points is in homogeneous coordinates because they need both translation and rotation, while the normals need only rotation. All channels contain scalar values of type ScalarType. */ - struct DataPoints + struct PM_EXPORT DataPoints { //! A view on a feature or descriptor typedef Eigen::Block View; @@ -218,7 +218,7 @@ struct PointMatcher typedef typename Matrix::Index Index; //! The name for a certain number of dim - struct Label + struct PM_EXPORT Label { std::string text; //!< name of the label size_t span; //!< number of data dimensions the label spans @@ -226,7 +226,7 @@ struct PointMatcher bool operator ==(const Label& that) const; }; //! A vector of Label - struct Labels: std::vector