Skip to content

Commit

Permalink
some minor fixes
Browse files Browse the repository at this point in the history
- default to static libs if building with MSVC
- fix some warnings
- handle OptimizationAlgorithm::solve() return value
  • Loading branch information
Rainer Kuemmerle committed Jan 13, 2012
1 parent fbc5ea2 commit 0ab1331
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
build
build*
lib
bin
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion g2o/core/sparse_optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
16 changes: 9 additions & 7 deletions g2o/stuff/command_args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ using namespace std;

namespace g2o {

// forward decl of some operators
std::istream& operator>>(std::istream& is, std::vector<int>& v);
std::ostream& operator<<(std::ostream& os, const std::vector<int>& v);


/** Helper class to sort pair based on first elem */
template<class T1, class T2, class Pred = std::less<T1> >
struct CmpPairFirst {
Expand Down Expand Up @@ -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<int>& v){
std::istream& operator>>(std::istream& is, std::vector<int>& 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<char*>(c);

strcpy(c, s.c_str());
v.clear();
bool hasNextValue=true;
while(hasNextValue){
Expand All @@ -455,11 +458,10 @@ std::istream& operator >> (std::istream& is, std::vector<int>& v){
} else
hasNextValue = false;
}
delete [] cbase;
return is;
}

std::ostream& operator << (std::ostream& os, const std::vector<int>& v){
std::ostream& operator<<(std::ostream& os, const std::vector<int>& v){
if (v.size()){
os << v[0];
}
Expand Down
3 changes: 0 additions & 3 deletions g2o/stuff/command_args.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ class CommandArgs
std::string trim(const std::string& s) const;
};

std::istream& operator>>(std::istream& is, std::vector<int>& v);
std::ostream& operator<<(std::ostream& os, const std::vector<int>& v);

} // end namespace

#endif
5 changes: 1 addition & 4 deletions g2o/types/slam3d/edge_se3_pointxyz_depth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0ab1331

Please sign in to comment.