1#ifndef BITMAPPRIMITIVESHAPE_HEADER
2#define BITMAPPRIMITIVESHAPE_HEADER
34 bool Init(
bool binary, std::istream* i);
38 bool doFiltering =
true,
39 float* borderRatio = 0);
46 bool doFiltering =
true);
51 std::deque<ComponentPolygons>* polys)
const;
59 virtual void Parameters(
const Vec3f& p, std::pair<float, float>* param)
const = 0;
73 virtual void InBitmap(
const std::pair<float, float>& param,
78 std::pair<int, int>* inBmp)
const = 0;
87 bool* vwrap)
const = 0;
102 template <
class IteratorT>
113 template <
class IteratorT>
124 size_t border)
const;
132 std::deque<ComponentPolygons>* polys)
const;
138template <
class IteratorT>
151 int size = end - begin;
152 params->resize(size);
157 std::numeric_limits<float>::infinity());
158 bbox->
Max() = -bbox->
Min();
159 for (
size_t i = 0; i < (size_t)size; ++i)
161 if ((*params)[i].first < bbox->Min()[0])
163 bbox->
Min()[0] = (*params)[i].first;
165 if ((*params)[i].first > bbox->
Max()[0])
167 bbox->
Max()[0] = (*params)[i].first;
169 if ((*params)[i].second < bbox->Min()[1])
171 bbox->
Min()[1] = (*params)[i].second;
173 if ((*params)[i].second > bbox->
Max()[1])
175 bbox->
Max()[1] = (*params)[i].second;
189 bitmap->
resize((*uextent) * (*vextent));
190 std::fill(bitmap->
begin(), bitmap->
end(),
false);
192 bmpIdx->
resize(params->size());
194 for (
int i = 0; i < size; ++i)
196 std::pair<int, int> bmpParam;
197 InBitmap((*params)[i], *epsilon, *bbox, *uextent, *vextent, &bmpParam);
201 (*bitmap)[(*bmpIdx)[i] = bmpParam.first + bmpParam.second * (*uextent)] =
true;
205template <
class IteratorT>
219 params->resize(end - begin);
225 for (++i; i != end; ++i, ++j)
228 if (bbox->
Min()[0] > (*params)[j].first)
230 bbox->
Min()[0] = (*params)[j].first;
232 else if (bbox->
Max()[0] < (*params)[j].first)
234 bbox->
Max()[0] = (*params)[j].first;
236 if (bbox->
Min()[1] > (*params)[j].second)
238 bbox->
Min()[1] = (*params)[j].second;
240 else if (bbox->
Max()[1] < (*params)[j].second)
242 bbox->
Max()[1] = (*params)[j].second;
256 bitmap->
resize(((*uextent) + 2 * border) * ((*vextent) + 2 * border));
257 std::fill(bitmap->
begin(), bitmap->
end(),
false);
259 bmpIdx->
resize(params->size());
260 size_t lineWidth = (*uextent) + 2 * border;
261 for (
size_t i = 0; i < params->size(); ++i)
263 std::pair<int, int> bmpParam;
264 InBitmap((*params)[i], *epsilon, *bbox, *uextent, *vextent, &bmpParam);
268 (*bitmap)[(*bmpIdx)[i] = bmpParam.first + border + (bmpParam.second + border) * lineWidth] =
virtual void WrapComponents(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, float epsilon, size_t uextent, size_t vextent, MiscLib::Vector< int > *componentImg, MiscLib::Vector< std::pair< int, size_t > > *labels) const
virtual void Parameters(const Vec3f &p, std::pair< float, float > *param) const =0
virtual void WrapBitmap(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, float epsilon, bool *uwrap, bool *vwrap) const =0
virtual void PreWrapBitmap(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, float epsilon, size_t uextent, size_t vextent, MiscLib::Vector< char > *bmp) const
virtual bool InSpace(float u, float v, Vec3f *p, Vec3f *n) const =0
bool Init(bool binary, std::istream *i)
void BuildPolygons(const PointCloud &pc, float epsilon, size_t begin, size_t end, GfxTL::AABox< GfxTL::Vector2Df > *bbox, size_t *uextent, size_t *vextent, std::deque< ComponentPolygons > *polys) const
virtual void Parameters(GfxTL::IndexedIterator< MiscLib::Vector< size_t >::iterator, PointCloud::const_iterator > begin, GfxTL::IndexedIterator< MiscLib::Vector< size_t >::iterator, PointCloud::const_iterator > end, MiscLib::Vector< std::pair< float, float > > *bmpParams) const =0
virtual void InBitmap(const std::pair< float, float > ¶m, float epsilon, const GfxTL::AABox< GfxTL::Vector2Df > &bbox, size_t uextent, size_t vextent, std::pair< int, int > *inBmp) const =0
virtual void BitmapExtent(float epsilon, GfxTL::AABox< GfxTL::Vector2Df > *bbox, MiscLib::Vector< std::pair< float, float > > *params, size_t *uextent, size_t *vextent)=0
size_t AllConnectedComponents(const PointCloud &pc, float epsilon, BitmapInfo &bitmapInfo, MiscLib::Vector< size_t > *indices, MiscLib::Vector< int > &componentsImg, MiscLib::Vector< std::pair< int, size_t > > &labels, bool doFiltering=true)
virtual bool InSpace(size_t u, size_t v, float epsilon, const GfxTL::AABox< GfxTL::Vector2Df > &bbox, size_t uextent, size_t vextent, Vec3f *p, Vec3f *n) const =0
void BuildBitmap(const PointCloud &pc, float *epsilon, IteratorT begin, IteratorT end, MiscLib::Vector< std::pair< float, float > > *params, GfxTL::AABox< GfxTL::Vector2Df > *bbox, MiscLib::Vector< char > *bitmap, size_t *uextent, size_t *vextent, MiscLib::Vector< size_t > *bmpIdx) const
virtual void Parameters(GfxTL::IndexedIterator< IndexIterator, PointCloud::const_iterator > begin, GfxTL::IndexedIterator< IndexIterator, PointCloud::const_iterator > end, MiscLib::Vector< std::pair< float, float > > *bmpParams) const =0
GfxTL::AABox< GfxTL::Vector2Df > m_extBbox
static ScalarT Clamp(ScalarT s, ScalarT bottom, ScalarT top)
void resize(size_type s, const value_type &v)
const Point * const_iterator
virtual void GenerateBitmapPoints(const PointCloud &pc, float epsilon, size_t begin, size_t end, PointCloud *bmpPc) const =0
virtual void TrimmingPolygons(const PointCloud &pc, float epsilon, size_t begin, size_t end, std::deque< ComponentPolygons > *polys) const =0
virtual size_t ConnectedComponent(const PointCloud &pc, float epsilon, MiscLib::Vector< size_t > *indices, bool doFiltering=true, float *borderRatio=0)=0
IndexedIterator< IndexIteratorT, IteratorT > IndexIterate(IndexIteratorT idxIt, IteratorT it)
VectorXD< 2, float > Vector2Df
MiscLib::Vector< char > bitmap
GfxTL::AABox< GfxTL::Vector2Df > bbox
MiscLib::Vector< std::pair< float, float > > params
MiscLib::Vector< size_t > bmpIdx