1 #ifndef BITMAPPRIMITIVESHAPE_HEADER
2 #define BITMAPPRIMITIVESHAPE_HEADER
34 bool Init(
bool binary, std::istream* i);
39 MiscLib::Vector< std::pair< int, size_t > >& labels,
bool doFiltering =
true);
41 size_t begin,
size_t end,
42 std::deque< ComponentPolygons >* polys)
const;
44 size_t begin,
size_t end,
PointCloud* bmpPc)
const;
48 std::pair< float, float >* param)
const = 0;
60 virtual void BitmapExtent(
float epsilon,
63 size_t* uextent,
size_t* vextent) = 0;
64 virtual void InBitmap(
const std::pair< float, float >& param,
66 size_t uextent,
size_t vextent,
67 std::pair< int, int >* inBmp)
const = 0;
69 float epsilon,
size_t uextent,
size_t vextent,
72 float epsilon,
bool* uwrap,
bool* vwrap)
const = 0;
74 float epsilon,
size_t uextent,
size_t vextent,
77 virtual bool InSpace(
size_t u,
size_t v,
float epsilon,
80 template<
class IteratorT >
81 void BuildBitmap(
const PointCloud&
pc,
float* epsilon, IteratorT begin,
86 template<
class IteratorT >
87 void BuildBitmap(
const PointCloud&
pc,
float* epsilon, IteratorT begin,
92 void BuildPolygons(
const PointCloud&
pc,
float epsilon,
size_t begin,
94 size_t* uextent,
size_t* vextent,
95 std::deque< ComponentPolygons >* polys)
const;
101 template<
class IteratorT >
103 IteratorT begin, IteratorT end,
MiscLib::Vector< std::pair< float, float > >* params,
107 int size = end - begin;
108 params->resize(size);
113 std::numeric_limits< float >::infinity());
114 bbox->
Max() = -bbox->
Min();
115 for (
size_t i = 0; i < (size_t)size; ++i)
117 if ((*params)[i].first < bbox->
Min()[0])
119 bbox->
Min()[0] = (*params)[i].first;
121 if ((*params)[i].first > bbox->
Max()[0])
123 bbox->
Max()[0] = (*params)[i].first;
125 if ((*params)[i].second < bbox->
Min()[1])
127 bbox->
Min()[1] = (*params)[i].second;
129 if ((*params)[i].second > bbox->
Max()[1])
131 bbox->
Max()[1] = (*params)[i].second;
146 bitmap->
resize((*uextent) * (*vextent));
147 std::fill(bitmap->
begin(), bitmap->
end(),
false);
149 bmpIdx->
resize(params->size());
151 for (
int i = 0; i < size; ++i)
153 std::pair< int, int > bmpParam;
154 InBitmap((*params)[i], *epsilon, *bbox, *uextent, *vextent, &bmpParam);
158 (*bitmap)[(*bmpIdx)[i] = bmpParam.first + bmpParam.second * (*uextent)] =
true;
162 template<
class IteratorT >
164 IteratorT begin, IteratorT end,
MiscLib::Vector< std::pair< float, float > >* params,
169 params->resize(end - begin);
173 (*params)[0].second);
176 for (++i; i != end; ++i, ++j)
179 if (bbox->
Min()[0] > (*params)[j].first)
181 bbox->
Min()[0] = (*params)[j].first;
183 else if (bbox->
Max()[0] < (*params)[j].first)
185 bbox->
Max()[0] = (*params)[j].first;
187 if (bbox->
Min()[1] > (*params)[j].second)
189 bbox->
Min()[1] = (*params)[j].second;
191 else if (bbox->
Max()[1] < (*params)[j].second)
193 bbox->
Max()[1] = (*params)[j].second;
208 bitmap->
resize(((*uextent) + 2 * border) * ((*vextent) + 2 * border));
209 std::fill(bitmap->
begin(), bitmap->
end(),
false);
211 bmpIdx->
resize(params->size());
212 size_t lineWidth = (*uextent) + 2 * border;
213 for (
size_t i = 0; i < params->size(); ++i)
215 std::pair< int, int > bmpParam;
216 InBitmap((*params)[i], *epsilon, *bbox, *uextent, *vextent, &bmpParam);
220 (*bitmap)[(*bmpIdx)[i] = bmpParam.first + border
221 + (bmpParam.second + border) * lineWidth] =
true;