Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
nav_grid_iterators::Spiral Class Reference

Iterates over all of the valid indexes that lie within a circle from the center out. More...

#include <spiral.h>

Inheritance diagram for nav_grid_iterators::Spiral:
Inheritance graph
[legend]

Public Member Functions

Spiraloperator= (const Spiral &other)
 Assignment Operator Required to ensure unique_ptr is set properly. More...
 
 Spiral (const nav_grid::NavGridInfo *info, double center_x, double center_y, double radius)
 Public Constructor. More...
 
 Spiral (const Spiral &other)
 Copy Constructor Required to ensure unique_ptr is set properly. More...
 
Standard BaseIterator Interface
Spiral begin () const override
 Helper function for range-style iteration Equivalent to the above constructor. More...
 
Spiral end () const override
 Helper function for range-style iteration. More...
 
void increment () override
 Increase the iterator to the next element. More...
 
bool fieldsEqual (const Spiral &other) override
 Additional check for whether fields of derived iterators are equal. More...
 
- Public Member Functions inherited from nav_grid_iterators::BaseIterator< Spiral >
 BaseIterator (const nav_grid::NavGridInfo *info)
 Public Constructor. Takes in a pointer to the info and starts at the minimum index. More...
 
 BaseIterator (const nav_grid::NavGridInfo &info)
 Public Constructor. Takes in a reference to the info and starts at the minimum index. More...
 
bool operator!= (const Spiral &other)
 Test if two iterators are not equivalent - required for testing if iterator is at the end. More...
 
const nav_grid::Indexoperator* () const
 Dereference the iterator. More...
 
Spiraloperator++ ()
 Increase the iterator to the next element. More...
 
bool operator== (const Spiral &other)
 Test if two iterators are equivalent. More...
 
virtual ~BaseIterator ()=default
 Destructor. More...
 

Protected Member Functions

bool isInside (unsigned int x, unsigned int y) const
 Check if the center of the given index is within the circle. More...
 
void loadRing ()
 Given a new distance value, loads the internal iterator. If there are no valid values in the internal iterator, increases the distance. More...
 
 Spiral (const nav_grid::NavGridInfo *info, const nav_grid::Index &index, double center_x, double center_y, double radius_sq, unsigned int distance, unsigned int max_distance, const nav_grid::Index &start_index)
 Protected constructor that takes in an arbitrary index and other internal parameters. More...
 
- Protected Member Functions inherited from nav_grid_iterators::BaseIterator< Spiral >
 BaseIterator (const nav_grid::NavGridInfo *info, const nav_grid::Index &index)
 Protected constructor that takes in an arbitrary index. More...
 

Protected Attributes

double center_x_
 
double center_y_
 
unsigned int distance_
 
std::unique_ptr< CircleOutlineinternal_iterator_
 
unsigned int max_distance_
 
double radius_sq_
 
nav_grid::Index start_index_
 
- Protected Attributes inherited from nav_grid_iterators::BaseIterator< Spiral >
nav_grid::Index index_
 
const nav_grid::NavGridInfoinfo_
 

Additional Inherited Members

- Public Types inherited from nav_grid_iterators::BaseIterator< Spiral >
using difference_type = int
 
using iterator_category = std::input_iterator_tag
 
using pointer = nav_grid::Index *
 
using reference = nav_grid::Index &
 
using self_type = Spiral
 
using value_type = nav_grid::Index
 

Detailed Description

Iterates over all of the valid indexes that lie within a circle from the center out.

Definition at line 48 of file spiral.h.

Constructor & Destructor Documentation

nav_grid_iterators::Spiral::Spiral ( const nav_grid::NavGridInfo info,
double  center_x,
double  center_y,
double  radius 
)

Public Constructor.

Parameters
infoNavGridInfo for the grid to iterate over
center_xCenter of the circle (x coordinate)
center_yCenter of the circle (y coordinate)
radiusSize of the circle

Definition at line 40 of file spiral.cpp.

nav_grid_iterators::Spiral::Spiral ( const Spiral other)

Copy Constructor Required to ensure unique_ptr is set properly.

Definition at line 50 of file spiral.cpp.

nav_grid_iterators::Spiral::Spiral ( const nav_grid::NavGridInfo info,
const nav_grid::Index index,
double  center_x,
double  center_y,
double  radius_sq,
unsigned int  distance,
unsigned int  max_distance,
const nav_grid::Index start_index 
)
protected

Protected constructor that takes in an arbitrary index and other internal parameters.

Parameters
infoNavGridInfo for the grid to iterate over
indexInitial index
center_xCenter of the circle (x coordinate)
center_yCenter of the circle (y coordinate)
radius_sqSquare of the size of the circle
distanceWhich ring of the spiral to start on
max_distanceThe maximum valid ring
start_indexThe first valid index in the spiral

Definition at line 56 of file spiral.cpp.

Member Function Documentation

Spiral nav_grid_iterators::Spiral::begin ( ) const
overridevirtual

Helper function for range-style iteration Equivalent to the above constructor.

Returns
Iterator representing beginning of the iteration

Implements nav_grid_iterators::BaseIterator< Spiral >.

Definition at line 89 of file spiral.cpp.

Spiral nav_grid_iterators::Spiral::end ( ) const
overridevirtual

Helper function for range-style iteration.

Returns
Iterator representing end of the iteration, with an invalid index

Implements nav_grid_iterators::BaseIterator< Spiral >.

Definition at line 94 of file spiral.cpp.

bool nav_grid_iterators::Spiral::fieldsEqual ( const Spiral other)
overridevirtual

Additional check for whether fields of derived iterators are equal.

Helps make overriding the == operator easy.

Reimplemented from nav_grid_iterators::BaseIterator< Spiral >.

Definition at line 127 of file spiral.cpp.

void nav_grid_iterators::Spiral::increment ( )
overridevirtual

Increase the iterator to the next element.

Implements nav_grid_iterators::BaseIterator< Spiral >.

Definition at line 100 of file spiral.cpp.

bool nav_grid_iterators::Spiral::isInside ( unsigned int  x,
unsigned int  y 
) const
protected

Check if the center of the given index is within the circle.

Returns
true if inside

Definition at line 145 of file spiral.cpp.

void nav_grid_iterators::Spiral::loadRing ( )
protected

Given a new distance value, loads the internal iterator. If there are no valid values in the internal iterator, increases the distance.

Definition at line 133 of file spiral.cpp.

Spiral & nav_grid_iterators::Spiral::operator= ( const Spiral other)

Assignment Operator Required to ensure unique_ptr is set properly.

Definition at line 70 of file spiral.cpp.

Member Data Documentation

double nav_grid_iterators::Spiral::center_x_
protected

Definition at line 108 of file spiral.h.

double nav_grid_iterators::Spiral::center_y_
protected

Definition at line 108 of file spiral.h.

unsigned int nav_grid_iterators::Spiral::distance_
protected

Definition at line 109 of file spiral.h.

std::unique_ptr<CircleOutline> nav_grid_iterators::Spiral::internal_iterator_
protected

Definition at line 111 of file spiral.h.

unsigned int nav_grid_iterators::Spiral::max_distance_
protected

Definition at line 109 of file spiral.h.

double nav_grid_iterators::Spiral::radius_sq_
protected

Definition at line 108 of file spiral.h.

nav_grid::Index nav_grid_iterators::Spiral::start_index_
protected

Definition at line 110 of file spiral.h.


The documentation for this class was generated from the following files:


nav_grid_iterators
Author(s):
autogenerated on Wed Jun 26 2019 20:06:20