GpuLaserDataIteratorImpl.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 
19 #ifndef GAZEBO_RENDERING_GPULASERDATAITERATORIMPL_HH_
20 #define GAZEBO_RENDERING_GPULASERDATAITERATORIMPL_HH_
21 
22 namespace gazebo
23 {
24  namespace rendering
25  {
26  template <typename F>
28  {
29  // Do nothing
30  }
31 
32  template <typename F>
34  const GpuLaserDataIterator<F> &_rvalue) const
35  {
36  return this->index == _rvalue.index;
37  }
38 
39  template <typename F>
41  const GpuLaserDataIterator<F> &_rvalue) const
42  {
43  return this->index != _rvalue.index;
44  }
45 
46  template <typename F>
48  {
49  return {
50  // range
51  this->data[this->index * this->skip + this->rangeOffset],
52  // intensity
53  this->data[this->index * this->skip + this->intensityOffset],
54  // beam
55  index / this->horizontalResolution,
56  // reading
57  index % this->horizontalResolution,
58  };
59  }
60 
61  template <typename F>
62  const std::unique_ptr<const GpuLaserData>
64  {
65  return std::unique_ptr<const GpuLaserData>(
66  new GpuLaserData(this->operator*()));
67  }
68 
69  template <typename F>
71  {
72  ++(this->index);
73  return *this;
74  }
75 
76  template <typename F>
78  {
79  GpuLaserDataIterator<F> copy = *this;
80  this->index++;
81  return copy;
82  }
83 
84  template <typename F>
86  {
87  --(this->index);
88  return *this;
89  }
90 
91  template <typename F>
93  {
94  GpuLaserDataIterator<F> copy = *this;
95  this->index--;
96  return copy;
97  }
98 
99  template <typename F>
101  const float *_data, const unsigned int _skip, unsigned int _rangeOffset,
102  const unsigned int _intensityOffset,
103  const unsigned int _horizontalResolution) : index(_index), data(_data),
104  skip(_skip), rangeOffset(_rangeOffset),
105  intensityOffset(_intensityOffset),
106  horizontalResolution(_horizontalResolution)
107  {
108  // Do nothing
109  }
110  }
111 }
112 
113 // GAZEBO_RENDERING_GPULASERDATAITERATORIMPL_HH_
114 #endif
struct containing info about a single ray measurement
Definition: GpuLaserDataIterator.hh:27
const GpuLaserData operator*() const
Dereference operator *iter.
Definition: GpuLaserDataIteratorImpl.hh:47
GpuLaserDataIterator< F > & operator++()
Advance iterator to next reading (prefix: ++it)
Definition: GpuLaserDataIteratorImpl.hh:70
GpuLaserDataIterator(const unsigned int _index, const float *_data, const unsigned int _skip, const unsigned int _rangeOffset, const unsigned int _intensityOffset, const unsigned int _horizontalResolution)
contstruct an iterator to a specified index
Definition: GpuLaserDataIteratorImpl.hh:100
~GpuLaserDataIterator()
Destructor.
Definition: GpuLaserDataIteratorImpl.hh:27
bool operator==(const GpuLaserDataIterator &_rvalue) const
Operator ==.
Definition: GpuLaserDataIteratorImpl.hh:33
GpuLaserDataIterator< F > & operator--()
Move itereator to previous (prefix: –it)
Definition: GpuLaserDataIteratorImpl.hh:85
const std::unique_ptr< const GpuLaserData > operator->() const
Dereference operator iter->
Definition: GpuLaserDataIteratorImpl.hh:63
const Bidirectional iterator for laser data
Definition: GpuLaserDataIterator.hh:53
bool operator!=(const GpuLaserDataIterator &_rvalue) const
Operator !=.
Definition: GpuLaserDataIteratorImpl.hh:40