52 #ifndef __PCL_ImageGeometry_h
53 #define __PCL_ImageGeometry_h
58 #include <pcl/Diagnostics.h>
68 #define m_width m_geometry->width
69 #define m_height m_geometry->height
70 #define m_numberOfChannels m_geometry->numberOfChannels
109 return m_numberOfChannels;
120 return m_numberOfChannels-1;
129 return c >= 0 && c < m_numberOfChannels;
137 return m_width <= 0 || m_height <= 0 || m_numberOfChannels <= 0;
147 return Rect( m_width, m_height );
154 template <
typename T>
157 return Includes( p.x, p.y );
164 template <
typename T>
167 return Includes( r.x0, r.y0, r.x1, r.y1 );
177 template <
typename T>
178 bool Includes( T x0, T y0, T x1, T y1 )
const noexcept
181 return Includes( x0, y0 ) && Includes( x1-T( 1 ), y1-T( 1 ) );
191 template <
typename T>
194 return x < m_width && y < m_height && x >= 0 && y >= 0;
201 template <
typename T>
204 return Intersects( r.x0, r.y0, r.x1, r.y1 );
214 template <
typename T>
218 return x0 < m_width && y0 < m_height && x1 > T( 0 ) && y1 > T( 0 );
225 template <
typename T>
228 return Clip( p.x, p.y );
240 template <
typename T>
241 bool Clip( T& x, T& y )
const noexcept
245 if ( x >= T( m_width ) ) x = T( m_width-1 );
246 else if ( x < T( 0 ) ) x = T( 0 );
249 if ( y >= T( m_height ) ) y = T( m_height-1 );
250 else if ( y < T( 0 ) ) y = T( 0 );
263 template <
typename T>
266 return Clip( r.x0, r.y0, r.x1, r.y1 );
282 template <
typename T>
283 bool Clip( T& x0, T& y0, T& x1, T& y1 )
const noexcept
289 if ( x0 >= T( m_width ) ) x0 = T( m_width ), ++out;
290 else if ( x0 < T( 0 ) ) x0 = T( 0 );
292 if ( y0 >= T( m_height ) ) y0 = T( m_height ), ++out;
293 else if ( y0 < T( 0 ) ) y0 = T( 0 );
295 if ( x1 > T( m_width ) ) x1 = T( m_width );
296 else if ( x1 <= T( 0 ) ) x1 = T( 0 ), ++out;
298 if ( y1 > T( m_height ) ) y1 = T( m_height );
299 else if ( y1 <= T( 0 ) ) y1 = T( 0 ), ++out;
318 return NumberOfPixels()*
size_type( m_numberOfChannels );
351 int numberOfChannels = 0;
353 Geometry() =
default;
354 Geometry(
const Geometry& ) =
default;
356 size_type NumberOfPixels() const noexcept
361 void Assign(
const Geometry& x ) noexcept
365 numberOfChannels = x.numberOfChannels;
368 void Reset() noexcept
370 width = height = numberOfChannels = 0;
374 Geometry* m_geometry =
nullptr;
376 ImageGeometry() =
default;
377 ImageGeometry(
const ImageGeometry& ) =
default;
378 ImageGeometry& operator =(
const ImageGeometry& ) =
default;
380 virtual ~ImageGeometry()
382 m_geometry =
nullptr;
385 void Swap( ImageGeometry& image ) noexcept
387 pcl::Swap( m_geometry, image.m_geometry );
395 #undef m_numberOfChannels
A generic point in the two-dimensional space.
A generic rectangle in the two-dimensional space.
Implements geometric properties of two-dimensional images.
int LastChannel() const noexcept
bool Intersects(const pcl::GenericRectangle< T > &r) const noexcept
bool Clip(pcl::GenericRectangle< T > &r) const noexcept
bool Includes(const GenericRectangle< T > &r) const noexcept
int Width() const noexcept
bool Intersects(T x0, T y0, T x1, T y1) const noexcept
bool Clip(T &x0, T &y0, T &x1, T &y1) const noexcept
distance_type PixelOffset(int x, int y) const noexcept
bool Clip(T &x, T &y) const noexcept
int Height() const noexcept
bool Includes(T x0, T y0, T x1, T y1) const noexcept
size_type NumberOfSamples() const noexcept
bool Includes(T x, T y) const noexcept
bool Clip(pcl::GenericPoint< T > &p) const noexcept
size_type NumberOfPixels() const noexcept
distance_type RowOffset(int y) const noexcept
int NumberOfChannels() const noexcept
Rect Bounds() const noexcept
bool IsEmpty() const noexcept
bool IsValidChannelIndex(int c) const noexcept
bool Includes(const GenericPoint< T > &p) const noexcept
void Swap(GenericPoint< T > &p1, GenericPoint< T > &p2) noexcept
void OrderRect(T &x0, T &y0, T &x1, T &y1) noexcept