SubmapIterator.cpp
Go to the documentation of this file.
00001 /*
00002  * SubmapIterator.hpp
00003  *
00004  *  Created on: Sep 22, 2014
00005  *      Author: Péter Fankhauser
00006  *   Institute: ETH Zurich, ANYbotics
00007  */
00008 
00009 #include "grid_map_core/iterators/SubmapIterator.hpp"
00010 #include "grid_map_core/GridMapMath.hpp"
00011 
00012 using namespace std;
00013 
00014 namespace grid_map {
00015 
00016 SubmapIterator::SubmapIterator(const grid_map::SubmapGeometry& submap)
00017     : SubmapIterator(submap.getGridMap(), submap.getStartIndex(), submap.getSize())
00018 {
00019 }
00020 
00021 SubmapIterator::SubmapIterator(const grid_map::GridMap& gridMap,
00022                                const grid_map::BufferRegion& bufferRegion)
00023     : SubmapIterator(gridMap, bufferRegion.getStartIndex(), bufferRegion.getSize())
00024 {
00025 }
00026 
00027 
00028 SubmapIterator::SubmapIterator(const grid_map::GridMap& 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 Index& SubmapIterator::operator *() const
00069 {
00070   return index_;
00071 }
00072 
00073 const Index& SubmapIterator::getSubmapIndex() const
00074 {
00075   return submapIndex_;
00076 }
00077 
00078 SubmapIterator& SubmapIterator::operator ++()
00079 {
00080   isPastEnd_ = !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 const Size& SubmapIterator::getSubmapSize() const
00091 {
00092   return submapSize_;
00093 }
00094 
00095 } /* namespace grid_map */
00096 


grid_map_core
Author(s): Péter Fankhauser
autogenerated on Tue Jul 9 2019 05:06:13