-
Notifications
You must be signed in to change notification settings - Fork 0
/
Atlas.h
79 lines (61 loc) · 1.7 KB
/
Atlas.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef ATLAS_H
#define ATLAS_H
#include <opencv2/opencv.hpp>
#include <string>
#include <vector>
#include <map>
enum class AtlasConfigType
{
JSON,
LUA
};
class AtlasItem;
class Atlas
{
private:
const int maxSize;
struct VirtualAtlas
{
const int index;
const std::vector<AtlasItem> &items;
const int maxSize;
cv::Point atlasSize = { 0, 0 };
std::map<int, cv::Point> itemsPosition;
VirtualAtlas() = delete;
VirtualAtlas( const std::vector<AtlasItem> &objects, const int idx, const int dim );
std::string MakeAtlasName( std::string str ) const;
bool drop( const AtlasItem &item, const int index );
};
std::vector<VirtualAtlas> virtualAtlases;
std::vector<AtlasItem> items;
bool drawDebugLines = false;
bool trimAtlasSize = true;
std::string atlasName{ "atlas" };
AtlasConfigType configType = AtlasConfigType::JSON;
void dropItemsOnAtlas();
void drawAtlas();
void writeConfigJson( std::string fileName );
void writeConfigLua( std::string fileName );
public:
Atlas() = delete;
Atlas( const int size );
~Atlas();
void AddItem( const AtlasItem &item );
void SetDrawDebugLines( bool value );
void SetTrimAtlasSize( bool value );
void SetAtlasName( const std::string &str );
void SetConfigFormat( AtlasConfigType t );
};
inline void Atlas::SetDrawDebugLines( bool value )
{
drawDebugLines = value;
}
inline void Atlas::SetTrimAtlasSize( bool value )
{
trimAtlasSize = value;
}
inline void Atlas::SetConfigFormat( AtlasConfigType t )
{
configType = t;
}
#endif // ATLAS_H