Line data Source code
1 :
2 : /* Copyright (c) 2009, Maxim Makhinya
3 : * 2010-2014, Stefan Eilemann <eile@eyescale.ch>
4 : *
5 : * This library is free software; you can redistribute it and/or modify it under
6 : * the terms of the GNU Lesser General Public License version 2.1 as published
7 : * by the Free Software Foundation.
8 : *
9 : * This library is distributed in the hope that it will be useful, but WITHOUT
10 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 : * details.
13 : *
14 : * You should have received a copy of the GNU Lesser General Public License
15 : * along with this library; if not, write to the Free Software Foundation, Inc.,
16 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 : */
18 :
19 : #ifndef EQ_ROI_EMPTY_SPACE_FINDER_H
20 : #define EQ_ROI_EMPTY_SPACE_FINDER_H
21 :
22 : #include <eq/client/types.h>
23 : #include <vector>
24 :
25 : namespace eq
26 : {
27 : /** @internal Finds largest empty regions. */
28 : class ROIEmptySpaceFinder
29 : {
30 : public:
31 3 : ROIEmptySpaceFinder() : _limAbs( 200 ), _limRel( .002f ), _mask( 0 ) {}
32 3 : virtual ~ROIEmptySpaceFinder(){};
33 :
34 : /** Updated data structure from a given mask. Limits should be
35 : re-initialized after calling this function */
36 : void update( const uint8_t* mask, const int32_t w, const int32_t h );
37 :
38 : /** Returns maximal empty pvp within a given pvp.
39 : Uses mask data from update to check if single block is empty! */
40 : PixelViewport getLargestEmptyArea( const PixelViewport& pvp ) const;
41 :
42 0 : void setLimits( const int16_t absolute, const float relative )
43 : {
44 0 : _limAbs = absolute;
45 0 : _limRel = relative;
46 0 : }
47 :
48 : private:
49 : uint16_t _getArea( const int32_t x, const int32_t y,
50 : const int32_t w, const int32_t h ) const;
51 :
52 : uint16_t _getArea( const int32_t w, const int32_t h,
53 : const uint16_t* data ) const;
54 :
55 : /** Updates dimensions, resizes data if needed */
56 : void _resize( const int32_t w, const int32_t h );
57 :
58 : bool _updateMaximalEmptyRegion( const int32_t x, const int32_t y,
59 : const int32_t w, const int32_t h,
60 : PixelViewport& pvp,
61 : const uint16_t* data ) const;
62 :
63 : int32_t _w;
64 : int32_t _h;
65 :
66 : int16_t _limAbs;
67 : float _limRel;
68 :
69 : Vectorus _data;
70 : const uint8_t* _mask;
71 : };
72 : }
73 :
74 : #endif // EQ_ROI_EMPTY_SPACE_FINDER_H
75 :
|