From 21dd6832ae0e2012dfb60d57b8cec0f43253bf81 Mon Sep 17 00:00:00 2001 From: "krzysztof.zurad" Date: Fri, 6 Jul 2018 11:30:25 +0200 Subject: [PATCH 01/16] Ignore vtk files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 85152fb6..c92fa187 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ *~ *.swp *.cur_trans +*.vtk build .ipynb_checkpoints/ From 7ed2783bb25c3eb7d94ce7b3bc3243e8882e0d77 Mon Sep 17 00:00:00 2001 From: "krzysztof.zurad" Date: Thu, 19 Jul 2018 19:03:24 +0200 Subject: [PATCH 02/16] Add file system dependency --- CMakeLists.txt | 1 + pointmatcher/IOFunctions.h | 1 + 2 files changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3e0a3a3..c6461e04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -379,6 +379,7 @@ target_include_directories(pointmatcher PRIVATE ${CMAKE_SOURCE_DIR}/pointmatcher add_definitions(-Wall) #target_link_libraries(pointmatcher ${yaml-cpp_LIBRARIES} ${libnabo_LIBRARIES}) target_link_libraries(pointmatcher ${EXTERNAL_LIBS}) +target_link_libraries(pointmatcher stdc++fs) if(EXTRA_DEPS) add_dependencies(pointmatcher ${EXTRA_DEPS}) diff --git a/pointmatcher/IOFunctions.h b/pointmatcher/IOFunctions.h index 1eb50367..ebfa2de6 100644 --- a/pointmatcher/IOFunctions.h +++ b/pointmatcher/IOFunctions.h @@ -41,6 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include namespace PointMatcherSupport { From e608557b7541a9e815df98731ccf74605ef3a649 Mon Sep 17 00:00:00 2001 From: "krzysztof.zurad" Date: Thu, 19 Jul 2018 19:05:28 +0200 Subject: [PATCH 03/16] Add UniqueName func to check if files already exists and append leading number to new file --- pointmatcher/IOFunctions.cpp | 12 ++++++++++++ pointmatcher/IOFunctions.h | 1 + 2 files changed, 13 insertions(+) diff --git a/pointmatcher/IOFunctions.cpp b/pointmatcher/IOFunctions.cpp index ea716fce..03ad9fad 100644 --- a/pointmatcher/IOFunctions.cpp +++ b/pointmatcher/IOFunctions.cpp @@ -37,4 +37,16 @@ std::istream & safeGetLine( std::istream& is, std::string & t) } } +std::experimental::filesystem::path uniqueName(const std::string &name) { + std::experimental::filesystem::path possibleName{name}; + auto stem = possibleName.stem().string(); + auto ext = possibleName.extension().string(); + for (int i=1; std::experimental::filesystem::exists(possibleName); ++i) { + std::ostringstream fn; + fn << "(" << i << ")" << stem << ext; + possibleName.replace_filename(fn.str()); + } + return possibleName; +} + }// namespace PointMatcherSupport diff --git a/pointmatcher/IOFunctions.h b/pointmatcher/IOFunctions.h index ebfa2de6..7ba4d1f2 100644 --- a/pointmatcher/IOFunctions.h +++ b/pointmatcher/IOFunctions.h @@ -157,6 +157,7 @@ std::istream & readVtkData(std::string dataType, bool readBinary, MatrixRef into //! Replaces getline for handling windows style CR/LF line endings std::istream & safeGetLine( std::istream& is, std::string & t); +std::experimental::filesystem::path uniqueName(const std::string &name); } // PointMatcherSupport From 54e1a4259f195fc320b5f4e32f6f531b3ca32811 Mon Sep 17 00:00:00 2001 From: "krzysztof.zurad" Date: Thu, 19 Jul 2018 19:07:45 +0200 Subject: [PATCH 04/16] Check if file is unique before saving it --- pointmatcher/InspectorsImpl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pointmatcher/InspectorsImpl.cpp b/pointmatcher/InspectorsImpl.cpp index 2b53129f..5fac663b 100644 --- a/pointmatcher/InspectorsImpl.cpp +++ b/pointmatcher/InspectorsImpl.cpp @@ -772,7 +772,8 @@ std::ostream* InspectorsImpl::VTKFileInspector::openStream(const std::string& { ostringstream oss; oss << baseFileName << "-" << role << "-" << iterationNumber << ".vtk"; - ofstream* file = new ofstream(oss.str().c_str()); + std::string finalFileName = PointMatcherSupport::uniqueName(oss.str()); + ofstream* file = new ofstream(finalFileName.c_str()); if (file->fail()) throw std::runtime_error("Couldn't open the file \"" + oss.str() + "\". Check if directory exist."); return file; From abc42d0ae678604081e400f2e4bc82a2ca8e990b Mon Sep 17 00:00:00 2001 From: Marcin Pilch Date: Mon, 23 Jul 2018 10:54:20 +0200 Subject: [PATCH 05/16] Changed library std::experimental::filesystem to boost::filesystem; Introduced directory selection - in progress --- CMakeLists.txt | 1 - pointmatcher/IOFunctions.cpp | 19 +++++++++--------- pointmatcher/IOFunctions.h | 3 +-- pointmatcher/InspectorsImpl.cpp | 19 ++++++++++++------ pointmatcher/PointMatcher.h | 34 +++++++++++++++++++-------------- 5 files changed, 44 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c6461e04..a3e0a3a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -379,7 +379,6 @@ target_include_directories(pointmatcher PRIVATE ${CMAKE_SOURCE_DIR}/pointmatcher add_definitions(-Wall) #target_link_libraries(pointmatcher ${yaml-cpp_LIBRARIES} ${libnabo_LIBRARIES}) target_link_libraries(pointmatcher ${EXTERNAL_LIBS}) -target_link_libraries(pointmatcher stdc++fs) if(EXTRA_DEPS) add_dependencies(pointmatcher ${EXTRA_DEPS}) diff --git a/pointmatcher/IOFunctions.cpp b/pointmatcher/IOFunctions.cpp index 03ad9fad..06c743d1 100644 --- a/pointmatcher/IOFunctions.cpp +++ b/pointmatcher/IOFunctions.cpp @@ -1,4 +1,5 @@ #include "IOFunctions.h" +#include "boost/filesystem.hpp" namespace PointMatcherSupport { @@ -37,16 +38,16 @@ std::istream & safeGetLine( std::istream& is, std::string & t) } } -std::experimental::filesystem::path uniqueName(const std::string &name) { - std::experimental::filesystem::path possibleName{name}; - auto stem = possibleName.stem().string(); - auto ext = possibleName.extension().string(); - for (int i=1; std::experimental::filesystem::exists(possibleName); ++i) { - std::ostringstream fn; - fn << "(" << i << ")" << stem << ext; - possibleName.replace_filename(fn.str()); +std::string uniqueName(const std::string &name) { + boost::filesystem::path possibleName(name); + + for (int i=1; boost::filesystem::exists(possibleName); ++i) { + std::string fn = "("; + fn += std::to_string(i) + ")" + name; + possibleName = fn; } - return possibleName; + + return possibleName.string(); } }// namespace PointMatcherSupport diff --git a/pointmatcher/IOFunctions.h b/pointmatcher/IOFunctions.h index 7ba4d1f2..7e25da0c 100644 --- a/pointmatcher/IOFunctions.h +++ b/pointmatcher/IOFunctions.h @@ -41,7 +41,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include namespace PointMatcherSupport { @@ -157,7 +156,7 @@ std::istream & readVtkData(std::string dataType, bool readBinary, MatrixRef into //! Replaces getline for handling windows style CR/LF line endings std::istream & safeGetLine( std::istream& is, std::string & t); -std::experimental::filesystem::path uniqueName(const std::string &name); +std::string uniqueName(const std::string &name); } // PointMatcherSupport diff --git a/pointmatcher/InspectorsImpl.cpp b/pointmatcher/InspectorsImpl.cpp index 5fac663b..7a5b5b7d 100644 --- a/pointmatcher/InspectorsImpl.cpp +++ b/pointmatcher/InspectorsImpl.cpp @@ -727,16 +727,16 @@ void InspectorsImpl::VTKFileInspector::init() { if (!bDumpIterationInfo) return; - + ostringstream oss; oss << baseFileName << "-iterationInfo.csv"; //std::cerr << "writing to " << oss.str() << std::endl; LOG_INFO_STREAM("writing to " << oss.str()); - this->streamIter = new ofstream(oss.str().c_str()); + this->streamIter = new ofstream(this->dumpPath + oss.str().c_str()); if (this->streamIter->fail()) throw std::runtime_error("Couldn't open the file \"" + oss.str() + "\". Check if directory exist."); - + } template @@ -761,7 +761,7 @@ std::ostream* InspectorsImpl::VTKFileInspector::openStream(const std::string& //std::cerr << "writing to " << oss.str() << std::endl; LOG_INFO_STREAM("writing to " << oss.str()); - ofstream* file = new ofstream(oss.str().c_str(), std::ios::binary); + ofstream* file = new ofstream(this->dumpPath + oss.str().c_str(), std::ios::binary); if (file->fail()) throw std::runtime_error("Couldn't open the file \"" + oss.str() + "\". Check if directory exist."); return file; @@ -772,8 +772,15 @@ std::ostream* InspectorsImpl::VTKFileInspector::openStream(const std::string& { ostringstream oss; oss << baseFileName << "-" << role << "-" << iterationNumber << ".vtk"; - std::string finalFileName = PointMatcherSupport::uniqueName(oss.str()); - ofstream* file = new ofstream(finalFileName.c_str()); + std::string finalFileName = PointMatcherSupport::uniqueName(oss.str()); + //std::cout << "finalFileName = " << finalFileName << endl; + if (this->dumpPath.back() != '/') { + this->dumpPath += "/"; + } + + std::cout << "Dump Full Path: " << this->dumpPath << std::endl; + + ofstream* file = new ofstream(this->dumpPath + finalFileName.c_str()); if (file->fail()) throw std::runtime_error("Couldn't open the file \"" + oss.str() + "\". Check if directory exist."); return file; diff --git a/pointmatcher/PointMatcher.h b/pointmatcher/PointMatcher.h index 8045a474..fa32c8f1 100644 --- a/pointmatcher/PointMatcher.h +++ b/pointmatcher/PointMatcher.h @@ -604,42 +604,48 @@ struct PointMatcher }; typedef typename TransformationCheckers::iterator TransformationCheckersIt; //!< alias typedef typename TransformationCheckers::const_iterator TransformationCheckersConstIt; //!< alias - + DEF_REGISTRAR(TransformationChecker) // --------------------------------- - + //! An inspector allows to log data at the different steps, for analysis. struct Inspector: public Parametrizable { - + Inspector(); Inspector(const std::string& className, const ParametersDoc paramsDoc, const Parameters& params); - - // + + // virtual ~Inspector(); virtual void init(); - + // performance statistics virtual void addStat(const std::string& name, double data); virtual void dumpStats(std::ostream& stream); virtual void dumpStatsHeader(std::ostream& stream); - - // data statistics + + // data statistics virtual void dumpIteration(const size_t iterationNumber, const TransformationParameters& parameters, const DataPoints& filteredReference, const DataPoints& reading, const Matches& matches, const OutlierWeights& outlierWeights, const TransformationCheckers& transformationCheckers); virtual void finish(const size_t iterationCount); + + virtual void setDumpPath(std::string path) { dumpPath = path; } + virtual std::string getDumpPath() const { return dumpPath; } + + protected: + std::string dumpPath; }; - - DEF_REGISTRAR(Inspector) - + + DEF_REGISTRAR(Inspector) + // --------------------------------- - + DEF_REGISTRAR_IFACE(Logger, PointMatcherSupport::Logger) // --------------------------------- - + // algorithms - + //! Stuff common to all ICP algorithms struct ICPChainBase { From fcb485c1841c47aaeb07df690cd1c1c5f48c7549 Mon Sep 17 00:00:00 2001 From: Marcin Pilch Date: Wed, 25 Jul 2018 14:25:37 +0200 Subject: [PATCH 06/16] Dump path validation moved from openStream to accessor of Inspector. --- pointmatcher/Inspector.cpp | 13 +++++++++++++ pointmatcher/InspectorsImpl.cpp | 12 +++--------- pointmatcher/PointMatcher.h | 4 ++-- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/pointmatcher/Inspector.cpp b/pointmatcher/Inspector.cpp index 6be00f05..553c1c89 100644 --- a/pointmatcher/Inspector.cpp +++ b/pointmatcher/Inspector.cpp @@ -86,5 +86,18 @@ template void PointMatcher::Inspector::finish(const size_t iterationCount) {} +template +void PointMatcher::Inspector::setAndValidateDumpPath(std::string path) { + if (!path.empty() && path.back() != '/') { + path += "/"; + } + dumpPath = path; +} + +template +std::string PointMatcher::Inspector::getDumpPath() const { + return dumpPath; +} + template struct PointMatcher::Inspector; template struct PointMatcher::Inspector; diff --git a/pointmatcher/InspectorsImpl.cpp b/pointmatcher/InspectorsImpl.cpp index 7a5b5b7d..89701171 100644 --- a/pointmatcher/InspectorsImpl.cpp +++ b/pointmatcher/InspectorsImpl.cpp @@ -771,16 +771,10 @@ template std::ostream* InspectorsImpl::VTKFileInspector::openStream(const std::string& role, const size_t iterationNumber) { ostringstream oss; - oss << baseFileName << "-" << role << "-" << iterationNumber << ".vtk"; - std::string finalFileName = PointMatcherSupport::uniqueName(oss.str()); - //std::cout << "finalFileName = " << finalFileName << endl; - if (this->dumpPath.back() != '/') { - this->dumpPath += "/"; - } - - std::cout << "Dump Full Path: " << this->dumpPath << std::endl; + oss << baseFileName << "-" << role << "-" << iterationNumber << ".vtk"; - ofstream* file = new ofstream(this->dumpPath + finalFileName.c_str()); + LOG_INFO_STREAM("writing to " << oss.str()); + ofstream* file = new ofstream(this->dumpPath + oss.str().c_str()); if (file->fail()) throw std::runtime_error("Couldn't open the file \"" + oss.str() + "\". Check if directory exist."); return file; diff --git a/pointmatcher/PointMatcher.h b/pointmatcher/PointMatcher.h index fa32c8f1..09dc19af 100644 --- a/pointmatcher/PointMatcher.h +++ b/pointmatcher/PointMatcher.h @@ -629,8 +629,8 @@ struct PointMatcher virtual void dumpIteration(const size_t iterationNumber, const TransformationParameters& parameters, const DataPoints& filteredReference, const DataPoints& reading, const Matches& matches, const OutlierWeights& outlierWeights, const TransformationCheckers& transformationCheckers); virtual void finish(const size_t iterationCount); - virtual void setDumpPath(std::string path) { dumpPath = path; } - virtual std::string getDumpPath() const { return dumpPath; } + virtual void setAndValidateDumpPath(std::string path); + virtual std::string getDumpPath() const; protected: std::string dumpPath; From 8e73d696c5dcde3618ea1e4a27a468acfbb4207a Mon Sep 17 00:00:00 2001 From: Marcin Pilch Date: Wed, 25 Jul 2018 18:56:28 +0200 Subject: [PATCH 07/16] Do not log iterations for reference cloud --- pointmatcher/InspectorsImpl.cpp | 13 ++++++++++--- pointmatcher/InspectorsImpl.h | 5 +++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pointmatcher/InspectorsImpl.cpp b/pointmatcher/InspectorsImpl.cpp index 89701171..8381ca04 100644 --- a/pointmatcher/InspectorsImpl.cpp +++ b/pointmatcher/InspectorsImpl.cpp @@ -142,7 +142,9 @@ InspectorsImpl::AbstractVTKInspector::AbstractVTKInspector(const std::string& bDumpDataLinks(Parametrizable::get("dumpDataLinks")), bDumpReading(Parametrizable::get("dumpReading")), bDumpReference(Parametrizable::get("dumpReference")), - bWriteBinary(Parametrizable::get("writeBinary")) + bWriteBinary(Parametrizable::get("writeBinary")), + bDumpReferenceOnlyFirstIter(Parametrizable::get("dumpReferenceOnlyFirstIter")), + isFirstIter(true) { } @@ -404,7 +406,10 @@ void InspectorsImpl::AbstractVTKInspector::dumpIteration( closeStream(streamRead); } - if (bDumpReference){ + if (bDumpReference && + ((bDumpReferenceOnlyFirstIter && isFirstIter) || !bDumpReferenceOnlyFirstIter) + ){ + isFirstIter = false; ostream* streamRef(openStream("reference", iterationNumber)); dumpDataPoints(filteredReference, *streamRef); closeStream(streamRef); @@ -718,7 +723,9 @@ InspectorsImpl::VTKFileInspector::VTKFileInspector(const Parameters& params): bDumpIterationInfo(Parametrizable::get("dumpIterationInfo")), bDumpDataLinks(Parametrizable::get("dumpDataLinks")), bDumpReading(Parametrizable::get("dumpReading")), - bDumpReference(Parametrizable::get("dumpReference")) + bDumpReference(Parametrizable::get("dumpReference")), + bDumpReferenceOnlyFirstIter(Parametrizable::get("dumpReferenceOnlyFirstIter")), + isFirstIter(true) { } diff --git a/pointmatcher/InspectorsImpl.h b/pointmatcher/InspectorsImpl.h index d780fb91..9f1336cc 100644 --- a/pointmatcher/InspectorsImpl.h +++ b/pointmatcher/InspectorsImpl.h @@ -120,6 +120,8 @@ struct InspectorsImpl const bool bDumpDataLinks; const bool bDumpReading; const bool bDumpReference; + const bool bDumpReferenceOnlyFirstIter; + bool isFirstIter; const bool bWriteBinary; public: @@ -172,6 +174,7 @@ struct InspectorsImpl {"dumpReading", "dump the reading cloud at each iteration", "0"}, {"dumpReference", "dump the reference cloud at each iteration", "0"}, {"writeBinary", "write binary VTK files", "0"} + {"dumpReferenceOnlyFirstIter", "dump the reference cloud only for the first iteration", "0"} }; } @@ -180,11 +183,13 @@ struct InspectorsImpl const bool bDumpDataLinks; const bool bDumpReading; const bool bDumpReference; + const bool bDumpReferenceOnlyFirstIter; protected: virtual std::ostream* openStream(const std::string& role); virtual std::ostream* openStream(const std::string& role, const size_t iterationCount); virtual void closeStream(std::ostream* stream); + bool isFirstIter; public: VTKFileInspector(const Parameters& params = Parameters()); From 9b7254d95aac38cc3886885dfb8ffe2d688b3954 Mon Sep 17 00:00:00 2001 From: Marcin Pilch Date: Wed, 22 Aug 2018 14:26:50 +0200 Subject: [PATCH 08/16] Removed obsolete function. --- pointmatcher/IOFunctions.cpp | 13 ------------- pointmatcher/IOFunctions.h | 2 -- 2 files changed, 15 deletions(-) diff --git a/pointmatcher/IOFunctions.cpp b/pointmatcher/IOFunctions.cpp index 06c743d1..ea716fce 100644 --- a/pointmatcher/IOFunctions.cpp +++ b/pointmatcher/IOFunctions.cpp @@ -1,5 +1,4 @@ #include "IOFunctions.h" -#include "boost/filesystem.hpp" namespace PointMatcherSupport { @@ -38,16 +37,4 @@ std::istream & safeGetLine( std::istream& is, std::string & t) } } -std::string uniqueName(const std::string &name) { - boost::filesystem::path possibleName(name); - - for (int i=1; boost::filesystem::exists(possibleName); ++i) { - std::string fn = "("; - fn += std::to_string(i) + ")" + name; - possibleName = fn; - } - - return possibleName.string(); -} - }// namespace PointMatcherSupport diff --git a/pointmatcher/IOFunctions.h b/pointmatcher/IOFunctions.h index 7e25da0c..ba22c341 100644 --- a/pointmatcher/IOFunctions.h +++ b/pointmatcher/IOFunctions.h @@ -156,8 +156,6 @@ std::istream & readVtkData(std::string dataType, bool readBinary, MatrixRef into //! Replaces getline for handling windows style CR/LF line endings std::istream & safeGetLine( std::istream& is, std::string & t); -std::string uniqueName(const std::string &name); - } // PointMatcherSupport From 4a15b47ce304482be85e093bb4a45ded7c94cbf3 Mon Sep 17 00:00:00 2001 From: Marcin Pilch Date: Thu, 23 Aug 2018 12:48:59 +0200 Subject: [PATCH 09/16] Added dumpPath for PerformanceInspector. --- pointmatcher/InspectorsImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pointmatcher/InspectorsImpl.cpp b/pointmatcher/InspectorsImpl.cpp index 8381ca04..5a8d75af 100644 --- a/pointmatcher/InspectorsImpl.cpp +++ b/pointmatcher/InspectorsImpl.cpp @@ -74,7 +74,7 @@ void InspectorsImpl::PerformanceInspector::addStat(const std::string& name, d HistogramMap::iterator it(stats.find(name)); if (it == stats.end()) { LOG_INFO_STREAM("Adding new stat: " << name); - it = stats.insert(HistogramMap::value_type(name, Histogram(16, name, baseFileName, bDumpPerfOnExit))).first; + it = stats.insert(HistogramMap::value_type(name, Histogram(16, name, this->dumpPath + baseFileName, bDumpPerfOnExit))).first; } it->second.push_back(data); } From eca32f05c855fdeb7620b01703b20431d7c48a65 Mon Sep 17 00:00:00 2001 From: Marcin Pilch Date: Mon, 27 Aug 2018 14:19:34 +0200 Subject: [PATCH 10/16] Whitespaces tidy-up. --- pointmatcher/Inspector.cpp | 10 +++++----- pointmatcher/InspectorsImpl.cpp | 28 ++++++++++++++-------------- pointmatcher/InspectorsImpl.h | 8 ++++---- pointmatcher/PointMatcher.h | 8 ++++---- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/pointmatcher/Inspector.cpp b/pointmatcher/Inspector.cpp index 553c1c89..2011f8b0 100644 --- a/pointmatcher/Inspector.cpp +++ b/pointmatcher/Inspector.cpp @@ -88,15 +88,15 @@ void PointMatcher::Inspector::finish(const size_t iterationCount) template void PointMatcher::Inspector::setAndValidateDumpPath(std::string path) { - if (!path.empty() && path.back() != '/') { - path += "/"; - } - dumpPath = path; + if (!path.empty() && path.back() != '/') { + path += "/"; + } + dumpPath = path; } template std::string PointMatcher::Inspector::getDumpPath() const { - return dumpPath; + return dumpPath; } template struct PointMatcher::Inspector; diff --git a/pointmatcher/InspectorsImpl.cpp b/pointmatcher/InspectorsImpl.cpp index 5a8d75af..6c2270df 100644 --- a/pointmatcher/InspectorsImpl.cpp +++ b/pointmatcher/InspectorsImpl.cpp @@ -142,9 +142,9 @@ InspectorsImpl::AbstractVTKInspector::AbstractVTKInspector(const std::string& bDumpDataLinks(Parametrizable::get("dumpDataLinks")), bDumpReading(Parametrizable::get("dumpReading")), bDumpReference(Parametrizable::get("dumpReference")), - bWriteBinary(Parametrizable::get("writeBinary")), - bDumpReferenceOnlyFirstIter(Parametrizable::get("dumpReferenceOnlyFirstIter")), - isFirstIter(true) + bWriteBinary(Parametrizable::get("writeBinary")), + bDumpReferenceOnlyFirstIter(Parametrizable::get("dumpReferenceOnlyFirstIter")), + isFirstIter(true) { } @@ -406,15 +406,15 @@ void InspectorsImpl::AbstractVTKInspector::dumpIteration( closeStream(streamRead); } - if (bDumpReference && - ((bDumpReferenceOnlyFirstIter && isFirstIter) || !bDumpReferenceOnlyFirstIter) - ){ - isFirstIter = false; + if (bDumpReference && + ((bDumpReferenceOnlyFirstIter && isFirstIter) || !bDumpReferenceOnlyFirstIter) + ){ + isFirstIter = false; ostream* streamRef(openStream("reference", iterationNumber)); dumpDataPoints(filteredReference, *streamRef); closeStream(streamRef); } - + if (!bDumpIterationInfo) return; // streamIter must be define by children @@ -723,9 +723,9 @@ InspectorsImpl::VTKFileInspector::VTKFileInspector(const Parameters& params): bDumpIterationInfo(Parametrizable::get("dumpIterationInfo")), bDumpDataLinks(Parametrizable::get("dumpDataLinks")), bDumpReading(Parametrizable::get("dumpReading")), - bDumpReference(Parametrizable::get("dumpReference")), - bDumpReferenceOnlyFirstIter(Parametrizable::get("dumpReferenceOnlyFirstIter")), - isFirstIter(true) + bDumpReference(Parametrizable::get("dumpReference")), + bDumpReferenceOnlyFirstIter(Parametrizable::get("dumpReferenceOnlyFirstIter")), + isFirstIter(true) { } @@ -778,10 +778,10 @@ template std::ostream* InspectorsImpl::VTKFileInspector::openStream(const std::string& role, const size_t iterationNumber) { ostringstream oss; - oss << baseFileName << "-" << role << "-" << iterationNumber << ".vtk"; + oss << baseFileName << "-" << role << "-" << iterationNumber << ".vtk"; - LOG_INFO_STREAM("writing to " << oss.str()); - ofstream* file = new ofstream(this->dumpPath + oss.str().c_str()); + LOG_INFO_STREAM("writing to " << oss.str()); + ofstream* file = new ofstream(this->dumpPath + oss.str().c_str()); if (file->fail()) throw std::runtime_error("Couldn't open the file \"" + oss.str() + "\". Check if directory exist."); return file; diff --git a/pointmatcher/InspectorsImpl.h b/pointmatcher/InspectorsImpl.h index 9f1336cc..78418730 100644 --- a/pointmatcher/InspectorsImpl.h +++ b/pointmatcher/InspectorsImpl.h @@ -120,8 +120,8 @@ struct InspectorsImpl const bool bDumpDataLinks; const bool bDumpReading; const bool bDumpReference; - const bool bDumpReferenceOnlyFirstIter; - bool isFirstIter; + const bool bDumpReferenceOnlyFirstIter; + bool isFirstIter; const bool bWriteBinary; public: @@ -183,13 +183,13 @@ struct InspectorsImpl const bool bDumpDataLinks; const bool bDumpReading; const bool bDumpReference; - const bool bDumpReferenceOnlyFirstIter; + const bool bDumpReferenceOnlyFirstIter; protected: virtual std::ostream* openStream(const std::string& role); virtual std::ostream* openStream(const std::string& role, const size_t iterationCount); virtual void closeStream(std::ostream* stream); - bool isFirstIter; + bool isFirstIter; public: VTKFileInspector(const Parameters& params = Parameters()); diff --git a/pointmatcher/PointMatcher.h b/pointmatcher/PointMatcher.h index 09dc19af..57d6d9b3 100644 --- a/pointmatcher/PointMatcher.h +++ b/pointmatcher/PointMatcher.h @@ -629,11 +629,11 @@ struct PointMatcher virtual void dumpIteration(const size_t iterationNumber, const TransformationParameters& parameters, const DataPoints& filteredReference, const DataPoints& reading, const Matches& matches, const OutlierWeights& outlierWeights, const TransformationCheckers& transformationCheckers); virtual void finish(const size_t iterationCount); - virtual void setAndValidateDumpPath(std::string path); - virtual std::string getDumpPath() const; + virtual void setAndValidateDumpPath(std::string path); + virtual std::string getDumpPath() const; - protected: - std::string dumpPath; + protected: + std::string dumpPath; }; DEF_REGISTRAR(Inspector) From 6851cab07ae1bc22ec5438b1d52087a456d00971 Mon Sep 17 00:00:00 2001 From: Marcin Pilch Date: Mon, 27 Aug 2018 14:23:42 +0200 Subject: [PATCH 11/16] Corrected indentation of 'if' condition. --- pointmatcher/InspectorsImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pointmatcher/InspectorsImpl.cpp b/pointmatcher/InspectorsImpl.cpp index 6c2270df..7280309a 100644 --- a/pointmatcher/InspectorsImpl.cpp +++ b/pointmatcher/InspectorsImpl.cpp @@ -408,7 +408,7 @@ void InspectorsImpl::AbstractVTKInspector::dumpIteration( if (bDumpReference && ((bDumpReferenceOnlyFirstIter && isFirstIter) || !bDumpReferenceOnlyFirstIter) - ){ + ){ isFirstIter = false; ostream* streamRef(openStream("reference", iterationNumber)); dumpDataPoints(filteredReference, *streamRef); From 554f43d8e2d5a134f7c24e62145e084f98a4488b Mon Sep 17 00:00:00 2001 From: Marcin Pilch Date: Mon, 27 Aug 2018 14:35:30 +0200 Subject: [PATCH 12/16] Reduced indentation of 'if' condition. --- pointmatcher/InspectorsImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pointmatcher/InspectorsImpl.cpp b/pointmatcher/InspectorsImpl.cpp index 7280309a..8c25db1d 100644 --- a/pointmatcher/InspectorsImpl.cpp +++ b/pointmatcher/InspectorsImpl.cpp @@ -407,7 +407,7 @@ void InspectorsImpl::AbstractVTKInspector::dumpIteration( } if (bDumpReference && - ((bDumpReferenceOnlyFirstIter && isFirstIter) || !bDumpReferenceOnlyFirstIter) + ((bDumpReferenceOnlyFirstIter && isFirstIter) || !bDumpReferenceOnlyFirstIter) ){ isFirstIter = false; ostream* streamRef(openStream("reference", iterationNumber)); From 9e21f05b1403901495705463c83386aebe50a36b Mon Sep 17 00:00:00 2001 From: Marcin Pilch Date: Tue, 28 Aug 2018 16:40:14 +0200 Subject: [PATCH 13/16] Removed duplicate fields in derived class. --- pointmatcher/InspectorsImpl.cpp | 4 +--- pointmatcher/InspectorsImpl.h | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/pointmatcher/InspectorsImpl.cpp b/pointmatcher/InspectorsImpl.cpp index 8c25db1d..bc1bab0b 100644 --- a/pointmatcher/InspectorsImpl.cpp +++ b/pointmatcher/InspectorsImpl.cpp @@ -723,9 +723,7 @@ InspectorsImpl::VTKFileInspector::VTKFileInspector(const Parameters& params): bDumpIterationInfo(Parametrizable::get("dumpIterationInfo")), bDumpDataLinks(Parametrizable::get("dumpDataLinks")), bDumpReading(Parametrizable::get("dumpReading")), - bDumpReference(Parametrizable::get("dumpReference")), - bDumpReferenceOnlyFirstIter(Parametrizable::get("dumpReferenceOnlyFirstIter")), - isFirstIter(true) + bDumpReference(Parametrizable::get("dumpReference")) { } diff --git a/pointmatcher/InspectorsImpl.h b/pointmatcher/InspectorsImpl.h index 78418730..d834e522 100644 --- a/pointmatcher/InspectorsImpl.h +++ b/pointmatcher/InspectorsImpl.h @@ -183,13 +183,11 @@ struct InspectorsImpl const bool bDumpDataLinks; const bool bDumpReading; const bool bDumpReference; - const bool bDumpReferenceOnlyFirstIter; protected: virtual std::ostream* openStream(const std::string& role); virtual std::ostream* openStream(const std::string& role, const size_t iterationCount); virtual void closeStream(std::ostream* stream); - bool isFirstIter; public: VTKFileInspector(const Parameters& params = Parameters()); From b37421dc3e0e1fd5cf250ca30e6bac1b7162eea9 Mon Sep 17 00:00:00 2001 From: Marcin Pilch Date: Tue, 28 Aug 2018 16:42:44 +0200 Subject: [PATCH 14/16] Fixed bug - only one reference cloud dumped when node keeps running between wrapping cycles. --- pointmatcher/InspectorsImpl.h | 2 ++ pointmatcher/PointMatcher.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/pointmatcher/InspectorsImpl.h b/pointmatcher/InspectorsImpl.h index d834e522..1f25c180 100644 --- a/pointmatcher/InspectorsImpl.h +++ b/pointmatcher/InspectorsImpl.h @@ -132,6 +132,8 @@ struct InspectorsImpl virtual void dumpIteration(const size_t iterationNumber, const TransformationParameters& parameters, const DataPoints& filteredReference, const DataPoints& reading, const Matches& matches, const OutlierWeights& outlierWeights, const TransformationCheckers& transformationCheckers); virtual void finish(const size_t iterationCount); + virtual void resetIsFirstIter() { isFirstIter = true; } + private: void buildGenericAttributeStream(std::ostream& stream, const std::string& attribute, const std::string& nameTag, const DataPoints& cloud, const int forcedDim); diff --git a/pointmatcher/PointMatcher.h b/pointmatcher/PointMatcher.h index 57d6d9b3..fc0bc1e3 100644 --- a/pointmatcher/PointMatcher.h +++ b/pointmatcher/PointMatcher.h @@ -632,6 +632,8 @@ struct PointMatcher virtual void setAndValidateDumpPath(std::string path); virtual std::string getDumpPath() const; + virtual void resetIsFirstIter() {} + protected: std::string dumpPath; }; From 373901b9593d7023c3ab1e1e626faaec80bc93b5 Mon Sep 17 00:00:00 2001 From: Marcin Pilch Date: Tue, 28 Aug 2018 17:16:11 +0200 Subject: [PATCH 15/16] Whitespace correction. --- pointmatcher/PointMatcher.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pointmatcher/PointMatcher.h b/pointmatcher/PointMatcher.h index fc0bc1e3..1c63319b 100644 --- a/pointmatcher/PointMatcher.h +++ b/pointmatcher/PointMatcher.h @@ -632,7 +632,7 @@ struct PointMatcher virtual void setAndValidateDumpPath(std::string path); virtual std::string getDumpPath() const; - virtual void resetIsFirstIter() {} + virtual void resetIsFirstIter() {} protected: std::string dumpPath; From 58712b37cf33085e789a475afc33218c136ed1e4 Mon Sep 17 00:00:00 2001 From: Marcin Pilch Date: Thu, 14 Mar 2019 15:53:43 +0100 Subject: [PATCH 16/16] Fix missing comma --- pointmatcher/InspectorsImpl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pointmatcher/InspectorsImpl.h b/pointmatcher/InspectorsImpl.h index 1f25c180..f6122f96 100644 --- a/pointmatcher/InspectorsImpl.h +++ b/pointmatcher/InspectorsImpl.h @@ -175,7 +175,7 @@ struct InspectorsImpl {"dumpDataLinks", "dump data links at each iteration", "0" }, {"dumpReading", "dump the reading cloud at each iteration", "0"}, {"dumpReference", "dump the reference cloud at each iteration", "0"}, - {"writeBinary", "write binary VTK files", "0"} + {"writeBinary", "write binary VTK files", "0"}, {"dumpReferenceOnlyFirstIter", "dump the reference cloud only for the first iteration", "0"} }; }