submap_iterator.cpp
Go to the documentation of this file.
00001 
00004 /*****************************************************************************
00005 ** Includes
00006 *****************************************************************************/
00007 
00008 #include <grid_map_core/GridMapMath.hpp>
00009 #include "../../../include/cost_map_core/iterators/submap_iterator.hpp"
00010 
00011 
00012 using namespace std;
00013 
00014 namespace cost_map {
00015 
00016 SubmapIterator::SubmapIterator(const cost_map::SubmapGeometry& submap)
00017     : SubmapIterator(submap.getGridMap(), submap.getStartIndex(), submap.getSize())
00018 {
00019 }
00020 
00021 SubmapIterator::SubmapIterator(const cost_map::CostMap& gridMap,
00022                                const cost_map::BufferRegion& bufferRegion)
00023     : SubmapIterator(gridMap, bufferRegion.getStartIndex(), bufferRegion.getSize())
00024 {
00025 }
00026 
00027 
00028 SubmapIterator::SubmapIterator(const cost_map::CostMap& gridMap, const Index& submapStartIndex,
00029                                const Size& submapSize)
00030 {
00031   size_ = gridMap.getSize();
00032   startIndex_ = gridMap.getStartIndex();
00033   index_ = submapStartIndex;
00034   submapSize_ = submapSize;
00035   submapStartIndex_ = submapStartIndex;
00036   submapIndex_.setZero();
00037   isPastEnd_ = false;
00038 }
00039 
00040 SubmapIterator::SubmapIterator(const SubmapIterator* other)
00041 {
00042   size_ = other->size_;
00043   startIndex_ = other->startIndex_;
00044   submapSize_ = other->submapSize_;
00045   submapStartIndex_ = other->submapStartIndex_;
00046   index_ = other->index_;
00047   submapIndex_ = other->submapIndex_;
00048   isPastEnd_ = other->isPastEnd_;
00049 }
00050 
00051 SubmapIterator& SubmapIterator::operator =(const SubmapIterator& other)
00052 {
00053   size_ = other.size_;
00054   startIndex_ = other.startIndex_;
00055   submapSize_ = other.submapSize_;
00056   submapStartIndex_ = other.submapStartIndex_;
00057   index_ = other.index_;
00058   submapIndex_ = other.submapIndex_;
00059   isPastEnd_ = other.isPastEnd_;
00060   return *this;
00061 }
00062 
00063 bool SubmapIterator::operator !=(const SubmapIterator& other) const
00064 {
00065   return (index_ != other.index_).any();
00066 }
00067 
00068 const Eigen::Array2i& SubmapIterator::operator *() const
00069 {
00070   return index_;
00071 }
00072 
00073 const Eigen::Array2i& SubmapIterator::getSubmapIndex() const
00074 {
00075   return submapIndex_;
00076 }
00077 
00078 SubmapIterator& SubmapIterator::operator ++()
00079 {
00080   isPastEnd_ = !grid_map::incrementIndexForSubmap(submapIndex_, index_, submapStartIndex_,
00081                                          submapSize_, size_, startIndex_);
00082   return *this;
00083 }
00084 
00085 bool SubmapIterator::isPastEnd() const
00086 {
00087   return isPastEnd_;
00088 }
00089 
00090 } /* namespace cost_map */
00091 


cost_map_core
Author(s): Daniel Stonier
autogenerated on Thu Jun 6 2019 20:27:46