VR-Forces 4.7 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtTextureAtlasIndexParser.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2015 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvCore/vrvCore.h>
15 
16 #include <boost/unordered_map.hpp>
17 #include <string>
18 
19 namespace makVrv
20 {
23  {
24  public:
27  struct AtlasResult
28  {
29  std::string annotation;
30  float uOffset;
31  float vOffset;
32  };
33 
37 
40  typedef std::pair<std::string, std::string> AttrValuePair;
41 
45  typedef std::vector<AttrValuePair> AttrValuePairVec;
46 
48  virtual ~DtTextureAtlasIndexParser();
49 
53  bool parseAtlasIfNecessary(const std::string& inputFile);
54 
57  bool retrieveTextureAtlasUV(const std::string& annotation,
58  const AttrValuePairVec& searchStringPairs,
59  float& u, float& v);
60 
63  bool retrieveTextureAtlasUV(const AttrValuePairVec & categoryValuePairs,
64  std::vector<AtlasResult>& results);
65 
67  bool hasSeen(const std::string& fileName);
68 
70  void setCurrentFile(const std::string& fileName);
71 
73  const std::string& currentFile() const;
74 
77  void setDefaultUV(float u, float v);
78 
80  void defaultUV(float& u, float& v);
81 
85  void setDefaultAttribute(const std::string& annotation);
86 
89  const std::string& defaultAttribute() const;
90 
94  void setDefaultValue(const std::string& value);
95 
98  const std::string& defaultValue() const;
99 
101  DtDe& de() { return myDe; }
102 
103  protected:
104 
107 
108  protected:
109  // valueUVMap["texture"] => { ("COLOUR", "Red"), .. ("U", "0.3"), ("V", "0.2") }
110  typedef boost::unordered_multimap<std::string, AttrValuePairVec > AnnotVecMap;
111  typedef boost::unordered_multimap<std::string, AttrValuePairVec >::iterator AnnotVecMapItr;
112 
113  // valueUVMap = FileMap["$(DATA)/objects/buoys/pillarBuoy.dtxc"]
114  typedef boost::unordered_map<std::string, AnnotVecMap> FileMap;
115  typedef boost::unordered_map<std::string, AnnotVecMap>::iterator FileMapItr;
116 
117  // For categories
118  typedef std::set<std::string> AttributeSet;
119  // Annotation -> categories ex. ( "COLOUR", "COLPAT", ... )
120  typedef boost::unordered_map<std::string, AttributeSet> AnnotAttrMap;
121  typedef boost::unordered_map<std::string, AnnotAttrMap> AttrMap;
122 
123  // map[file][annotation] = { ("COLOUR", "Red"), .. ("U", "0.3"), ("V", "0.2") }
125 
126  // map[file][annotation1] = { COLOUR, COLPAT, CATSPM }
127  // map[file][annotation2] = { CATSPM, TOPSHP }
129 
130  std::string myCurrentAtlasIndex;
131 
132  // If we can't find anything, provide a global default
133  float myDefaultU;
134  float myDefaultV;
135 
136  // If we can't find our pair, look for DEFAULT, default
137  std::string myDefaultAnnotation;
138  std::string myDefaultValue;
139 
141  };
142 
143 
147  {
148 
149  public:
151  static DtTextureAtlasIndexParserCreator& instance( DtDe& de );
152 
154  static void registerInstance( DtDe& de, DtTextureAtlasIndexParserCreator* anInstance );
155 
157  virtual DtTextureAtlasIndexParser* create(DtDe& de);
158  };
159 
160 }

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)