diff --git a/.gitignore b/.gitignore index 7a7c8b9c..4101016e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -build +build* lib bin diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cd3a08c..fe57595f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,11 @@ ELSEIF(CMAKE_BUILD_TYPE MATCHES MinSizeRel) ENDIF(CMAKE_BUILD_TYPE MATCHES Release) # Allow the developer to select if Dynamic or Static libraries are built -OPTION (BUILD_SHARED_LIBS "Build Shared Libraries (preferred and required for the g2o plugin system)" ON) +IF(MSVC) # MSVC only works if we link statically + OPTION (BUILD_SHARED_LIBS "Build Shared Libraries (preferred and required for the g2o plugin system)" OFF) +ELSE(MSVC) + OPTION (BUILD_SHARED_LIBS "Build Shared Libraries (preferred and required for the g2o plugin system)" ON) +ENDIF() SET (G2O_LIB_TYPE STATIC) IF (BUILD_SHARED_LIBS) SET (G2O_LIB_TYPE SHARED) diff --git a/g2o/core/sparse_optimizer.cpp b/g2o/core/sparse_optimizer.cpp index 020e4710..1ec3af6f 100644 --- a/g2o/core/sparse_optimizer.cpp +++ b/g2o/core/sparse_optimizer.cpp @@ -325,7 +325,7 @@ namespace g2o{ double ts = get_time(); - ok = _algorithm->solve(i, online); + ok = _algorithm->solve(i, online) == OptimizationAlgorithm::OK; bool errorComputed = false; if (cstat) { diff --git a/g2o/stuff/command_args.cpp b/g2o/stuff/command_args.cpp index a2aec3d6..f7d3b4e7 100644 --- a/g2o/stuff/command_args.cpp +++ b/g2o/stuff/command_args.cpp @@ -43,6 +43,11 @@ using namespace std; namespace g2o { +// forward decl of some operators +std::istream& operator>>(std::istream& is, std::vector& v); +std::ostream& operator<<(std::ostream& os, const std::vector& v); + + /** Helper class to sort pair based on first elem */ template > struct CmpPairFirst { @@ -434,16 +439,14 @@ std::string CommandArgs::trim(const std::string& s) const return std::string(s, b, e - b + 1); } -std::istream& operator >> (std::istream& is, std::vector& v){ +std::istream& operator>>(std::istream& is, std::vector& v){ string s; if (! (is >> s) ) return is; - char* cbase=new char[s.length()]; - char* c=cbase; - char* caux=cbase; + const char* c = s.c_str(); + char* caux = const_cast(c); - strcpy(c, s.c_str()); v.clear(); bool hasNextValue=true; while(hasNextValue){ @@ -455,11 +458,10 @@ std::istream& operator >> (std::istream& is, std::vector& v){ } else hasNextValue = false; } - delete [] cbase; return is; } -std::ostream& operator << (std::ostream& os, const std::vector& v){ +std::ostream& operator<<(std::ostream& os, const std::vector& v){ if (v.size()){ os << v[0]; } diff --git a/g2o/stuff/command_args.h b/g2o/stuff/command_args.h index 045a480c..f749e0cc 100644 --- a/g2o/stuff/command_args.h +++ b/g2o/stuff/command_args.h @@ -131,9 +131,6 @@ class CommandArgs std::string trim(const std::string& s) const; }; - std::istream& operator>>(std::istream& is, std::vector& v); - std::ostream& operator<<(std::ostream& os, const std::vector& v); - } // end namespace #endif diff --git a/g2o/types/slam3d/edge_se3_pointxyz_depth.cpp b/g2o/types/slam3d/edge_se3_pointxyz_depth.cpp index f765d876..2ee8ae6b 100644 --- a/g2o/types/slam3d/edge_se3_pointxyz_depth.cpp +++ b/g2o/types/slam3d/edge_se3_pointxyz_depth.cpp @@ -18,12 +18,9 @@ namespace g2o { ParameterVector pv(1); pv[0]=params; resolveCache(cache, (OptimizableGraph::Vertex*)_vertices[0],"CACHE_CAMERA",pv); - return cache; + return cache != 0; } - - - bool EdgeSE3PointXYZDepth::read(std::istream& is) { int pid; is >> pid;