VR-Forces Developer's Guide
 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) 2023 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvCore/vrvCore.h>
13 #include <vrvMath/DtVector2.h>
15 
16 #include <unordered_map>
17 #include <mutex>
18 #include <string>
19 
20 namespace makVrv
21 {
24 
27 
29  template <>
30  inline const char* creatorTypeName<DtTextureAtlasIndexParser>(void) { return "DtTextureAtlasIndexParserCreator"; }
31 
34  {
35  public:
38  struct AtlasResult
39  {
40  std::string annotation;
41  float uOffset;
42  float vOffset;
43  };
44 
48 
51  std::string myText;
52  float myValue;
53  StringOrFloatAttrib(const std::string& name) : myText(name), myValue(0) { ; }
54  StringOrFloatAttrib(const std::string& name, float value) : myText(name), myValue(value) { ; }
55  };
58  typedef std::pair<std::string, StringOrFloatAttrib> AttrValuePair;
59 
63  typedef std::vector<AttrValuePair> AttrValuePairVec;
64 
66  virtual ~DtTextureAtlasIndexParser();
67 
71  virtual bool parseAtlasIfNecessary(const std::string& inputFile);
72 
75  virtual bool retrieveTextureAtlasUV(const std::string& annotation,
76  const AttrValuePairVec& searchStringPairs,
77  float& u, float& v);
78 
81  virtual bool retrieveTextureAtlasUV(const AttrValuePairVec & categoryValuePairs,
82  std::vector<AtlasResult>& results);
83 
85  virtual bool hasSeen(const std::string& fileName);
86 
88  virtual void setCurrentFile(const std::string& fileName);
89 
91  virtual const std::string& currentFile() const;
92 
95  virtual void setDefaultUV(float u, float v);
96 
98  virtual void defaultUV(float& u, float& v);
99 
103  virtual void setDefaultAttribute(const std::string& annotation);
104 
107  virtual const std::string& defaultAttribute() const;
108 
112  virtual void setDefaultValue(const std::string& value);
113 
116  virtual const std::string& defaultValue() const;
117 
118  protected:
119 
122 
123  protected:
124  // valueUVMap["texture"] => { ("COLOUR", "Red"), .. ("U", "0.3"), ("V", "0.2") }
125  typedef std::unordered_multimap<std::string, AttrValuePairVec > AnnotVecMap;
126  typedef std::unordered_multimap<std::string, AttrValuePairVec >::iterator AnnotVecMapItr;
127 
128  // valueUVMap = FileMap["$(DATA)/objects/buoys/pillarBuoy.dtxc"]
129  typedef std::unordered_map<std::string, AnnotVecMap> FileMap;
130  typedef std::unordered_map<std::string, AnnotVecMap>::iterator FileMapItr;
131 
132  // For categories
133  typedef std::set<std::string> AttributeSet;
134  // Annotation -> categories ex. ( "COLOUR", "COLPAT", ... )
135  typedef std::unordered_map<std::string, AttributeSet> AnnotAttrMap;
136  typedef std::unordered_map<std::string, AnnotAttrMap> AttrMap;
137 
138  // map[file][annotation] = { ("COLOUR", "Red"), .. ("U", "0.3"), ("V", "0.2") }
140 
141  // map[file][annotation1] = { COLOUR, COLPAT, CATSPM }
142  // map[file][annotation2] = { CATSPM, TOPSHP }
144 
145  std::string myCurrentAtlasIndex;
146 
147  // If we can't find anything, provide a global default
148  float myDefaultU;
149  float myDefaultV;
150 
151  // If we can't find our pair, look for DEFAULT, default
152  std::string myDefaultAnnotation;
153  std::string myDefaultValue;
154 
155  std::mutex myDataMutex;
157  };
158 
161  return lhs.myText == rhs.myText;
162  }
163 }
std::unordered_multimap< std::string, AttrValuePairVec >::iterator AnnotVecMapItr
Definition: DtTextureAtlasIndexParser.h:126
Virtual base class. Allows for RTTI and proper virtual destruction. Used by Creators, Factories, Providers, Assemblers and User Interfaces.
Definition: DtVirtualBaseClass.h:19
StringOrFloatAttrib(const std::string &name)
Definition: DtTextureAtlasIndexParser.h:53
std::unordered_map< std::string, AnnotAttrMap > AttrMap
Definition: DtTextureAtlasIndexParser.h:136
float vOffset
Definition: DtTextureAtlasIndexParser.h:42
friend DtTextureAtlasIndexParserCreator
Instances of DtTextureAtlasIndexParser must be created through the creator function.
Definition: DtTextureAtlasIndexParser.h:47
std::string myDefaultAnnotation
Definition: DtTextureAtlasIndexParser.h:152
2 dimensional vector
std::mutex myDataMutex
Definition: DtTextureAtlasIndexParser.h:155
Results for setting UV offsets ex. (annotation=&quot;texture1&quot;, uOffset=0.1, vOffset=-0.25)
Definition: DtTextureAtlasIndexParser.h:38
std::unordered_multimap< std::string, AttrValuePairVec > AnnotVecMap
Definition: DtTextureAtlasIndexParser.h:125
std::string myText
Definition: DtTextureAtlasIndexParser.h:51
Definition: DtTextureAtlasIndexParser.h:33
std::vector< AttrValuePair > AttrValuePairVec
Typedef for a vector of S-57 attribute/value pairs and a UV coord ex. v = { (&quot;COLOUR&quot;, &quot;Red&quot;), (&quot;COLPAT&quot;, &quot;HorizontalStriped&quot;) , ...., (&quot;U&quot;, &quot;0.1&quot;), (&quot;V&quot;, &quot;0.2&quot;) }.
Definition: DtTextureAtlasIndexParser.h:63
std::string annotation
Definition: DtTextureAtlasIndexParser.h:40
std::set< std::string > AttributeSet
Definition: DtTextureAtlasIndexParser.h:133
std::string myCurrentAtlasIndex
Definition: DtTextureAtlasIndexParser.h:145
float uOffset
Definition: DtTextureAtlasIndexParser.h:41
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:23
StringOrFloatAttrib(const std::string &name, float value)
Definition: DtTextureAtlasIndexParser.h:54
#define DT_DLL_VRVCORE
Definition: vrvCore.h:20
struct for capturing the floating point value to avoid parsing constantly.
Definition: DtTextureAtlasIndexParser.h:50
FileMap myFileAttrValueUVMap
Definition: DtTextureAtlasIndexParser.h:139
std::unordered_map< std::string, AnnotVecMap >::iterator FileMapItr
Definition: DtTextureAtlasIndexParser.h:130
DtVirtualBaseClassCreator< DtTextureAtlasIndexParser > DtTextureAtlasIndexParserCreator
creator
Definition: DtTextureAtlasIndexParser.h:23
AttrMap myAttributeOnlyMap
Definition: DtTextureAtlasIndexParser.h:143
float myDefaultU
Definition: DtTextureAtlasIndexParser.h:148
DtDe & myDe
Definition: DtTextureAtlasIndexParser.h:156
bool operator==(const DtTextureAtlasIndexParser::StringOrFloatAttrib &lhs, const DtTextureAtlasIndexParser::StringOrFloatAttrib &rhs)
needed for search comparison code
Definition: DtTextureAtlasIndexParser.h:160
std::unordered_map< std::string, AttributeSet > AnnotAttrMap
Definition: DtTextureAtlasIndexParser.h:135
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:76
std::unordered_map< std::string, AnnotVecMap > FileMap
Definition: DtTextureAtlasIndexParser.h:129
std::pair< std::string, StringOrFloatAttrib > AttrValuePair
Typedef for S-57 attribute/value pairs valuePair = (&quot;COLOUR&quot;, &quot;Red&quot;) = ( attribute, value )
Definition: DtTextureAtlasIndexParser.h:58
float myDefaultV
Definition: DtTextureAtlasIndexParser.h:149
std::string myDefaultValue
Definition: DtTextureAtlasIndexParser.h:153
float myValue
Definition: DtTextureAtlasIndexParser.h:52
const char * creatorTypeName< DtTextureAtlasIndexParser >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtTextureAtlasIndexParser.h:30
Contains DLL export macros.

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)