HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_SaveOptions.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GA_SaveOptions.h (GA Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GA_SaveOptions__
12 #define __GA_SaveOptions__
13 
14 #include "GA_API.h"
15 #include <UT/UT_Options.h>
16 
17 /// Class to specify options for loading geometry.
18 ///
19 /// In addition, when saving to JSON format, see UT_JSONWriter for options.
20 /// Any options prefixed with 'json:' will be interpreted by the JSON writer
21 /// (i.e. json:indentstep).
22 ///
23 /// For each option, there are five methods created: @code
24 /// static const char *optionName() { return "name"; }
25 /// TYPE option(TYPE defval=DEFAULT) const
26 /// { return importOption(name,v) ? v : defval; }
27 /// bool importOption(TYPE &v) const { return importOption(name,v); }
28 /// void setOption() { setOption<>(name, v); }
29 /// @endcode
31 {
32 public:
34  : UT_Options()
35  {
36  }
37  ~GA_SaveOptions() override;
38 
40  {
42  return *this;
43  }
44 
45 #define BOOL_ACCESSOR(NAME, GET, IMPORT, SET, DEFAULT) \
46  static const char *GET##Name() { return NAME; } \
47  bool IMPORT(bool &v) const { return importOption(NAME, v); } \
48  bool GET() const { \
49  bool v; \
50  if (!importOption(NAME, v)) v = DEFAULT; \
51  return v; \
52  } \
53  void SET(bool v) { setOptionB(UTmakeUnsafeRef(NAME), v); }
54 #define INT_ACCESSOR(NAME, GET, IMPORT, SET, DEFAULT) \
55  static const char *GET##Name() { return NAME; } \
56  bool IMPORT(int32 &v) const { return importOption(NAME, v); } \
57  bool IMPORT(int64 &v) const { return importOption(NAME, v); } \
58  int64 GET() const { \
59  int64 v; \
60  if (!importOption(NAME, v)) v = DEFAULT; \
61  return v; \
62  } \
63  void SET(int64 v) { setOptionI(UTmakeUnsafeRef(NAME), v); }
64 #define REAL_ACCESSOR(NAME, GET, IMPORT, SET, DEFAULT) \
65  static const char *GET##Name() { return NAME; } \
66  bool IMPORT(fpreal32 &v) const { return importOption(NAME, v); } \
67  bool IMPORT(fpreal64 &v) const { return importOption(NAME, v); } \
68  fpreal64 GET() const { \
69  fpreal64 v; \
70  if (!importOption(NAME, v)) v = DEFAULT; \
71  return v; \
72  } \
73  void SET(fpreal64 v) { setOptionI(UTmakeUnsafeRef(NAME), v); }
74 #define STR_ACCESSOR(NAME, GET, IMPORT, SET) \
75  static const char *GET##Name() { return NAME; } \
76  bool IMPORT(UT_StringHolder &v) const { return importOption(NAME, v); } \
77  UT_StringHolder GET() const { return getOptionS(NAME); } \
78  void SET(const UT_StringHolder &v) { setOptionS(UTmakeUnsafeRef(NAME), v); }
79 
80  /// @{
81  /// Explicitly specify the format for the geometry (see the @c gconvert
82  /// command for available options).
83  STR_ACCESSOR("geo:format", format, importFormat, setFormat)
84  /// @}
85  /// @{
86  /// Explicitly specify the extension for the save file (this is used when
87  /// saving to a stream).
88  STR_ACCESSOR("geo:extension", extension, importExtension, setExtension)
89  /// @}
90 
91  /// @{
92  /// Save the info block in the geometry file. The info block contains the
93  /// bounding box of the geometry, a summary of attributes, and other useful
94  /// information. However, saving this information requires additional
95  /// computation, which adds to the cost of saving a file. Having this
96  /// information available makes querying the geometry much more efficient.
97  ///
98  /// Any options which begin with the prefix "info:" will be written to the
99  /// info block. Common info options are: the software used to save the
100  /// geometry, the artist name, the hostname and a comment. Most of these
101  /// are filled in automatically, but can be overridden with the methods
102  /// provided here.
103  BOOL_ACCESSOR("geo:saveinfo", saveInfo, importSaveInfo, setSaveInfo, true)
104  STR_ACCESSOR("info:software", software, importSoftware, setSoftware)
105  STR_ACCESSOR("info:artist", artist, importArtist, setArtist)
106  STR_ACCESSOR("info:hostname", hostname, importHostname, setHostname)
107  STR_ACCESSOR("info:comment", comment, importComment, setComment)
108  /// @}
109 
110  /// @{
111  /// When saving to a stream (without a filename), indicate whether the
112  /// stream should be binary or ASCII.
113  BOOL_ACCESSOR("geo:binary", binary, importBinary, setBinary, false)
114  /// @}
115 
116  /// @{
117  /// When saving to a stream (without a filename), indicate whether the
118  /// stream should have gzip compression.
119  BOOL_ACCESSOR("geo:gzip", gzip, importGZip, setGZip, false)
120  /// @}
121 
122  /// @{
123  /// When saving to a stream (without a filename), indicate whether the
124  /// stream should have blosc compression.
125  BOOL_ACCESSOR("geo:blosc", blosc, importBlosc, setBlosc, false)
126  /// @}
127 
128  /// @{
129  /// Option used to save all groups
130  BOOL_ACCESSOR("geo:savegroups", saveGroups, importSaveGroups,
131  setSaveGroups, true)
132  /// @}
133 
134  /// @{
135  /// Option used to save point groups
136  BOOL_ACCESSOR("geo:savepointgroups", savePointGroups,
137  importSavePointGroups, setSavePointGroups, true)
138  /// @}
139  /// @{
140  /// Option used to save vertex groups
141  BOOL_ACCESSOR("geo:savevertexgroups", saveVertexGroups,
142  importSaveVertexGroups, setSaveVertexGroups, true)
143  /// @}
144  /// @{
145  /// Option used to save edge groups
146  BOOL_ACCESSOR("geo:saveedgegroups", saveEdgeGroups,
147  importSaveEdgeGroups, setSaveEdgeGroups, true)
148  /// @}
149 
150  /// @{
151  /// Save groups using RLE encoding of bit stream
152  BOOL_ACCESSOR("geo:rlebits", rleBits, importRleBits, setRleBits, true)
153  /// @}
154 
155  /// @{
156  /// Whether to save data arrays using paged structures of flat
157  BOOL_ACCESSOR("geo:savepaged", savePaged,
158  importSavePaged, setSavePaged, true)
159  /// @}
160 
161  /// @{
162  /// How to check for constant pages when saving
163  /// - 0: No constant page optimization
164  /// - 1: Use pre-computed page state
165  /// - 2: Full test for constant pages
166  INT_ACCESSOR("geo:constpagecheck", constPageCheck,
167  importConstPageCheck, setConstPageCheck, 2)
168  /// @}
169 
170  /// @{
171  /// Option used to save primitive groups (default true)
172  BOOL_ACCESSOR("geo:saveprimitivegroups", savePrimitiveGroups,
173  importSavePrimitiveGroups, setSavePrimitiveGroups, true)
174  /// @}
175 
176  /// @{
177  /// Option used to enable saving runs of the same primitive types
178  BOOL_ACCESSOR("geo:primrun", primRun, importPrimRun, setPrimRun, true)
179  /// @}
180 
181  /// @{
182  /// Option to specify how many common primitives need to exist in a run
183  /// before they are merged into a single run.
184  INT_ACCESSOR("geo:primrunqueue", primRunQueue,
185  importPrimRunQueue, setPrimRunQueue, 4)
186  /// @}
187 
188  /// @{
189  /// When saving binary geometry, any delayed load sections (i.e. packed
190  /// geometry, etc.) are "indexed" which allows for partial loading of
191  /// geometry. This option can turn the feature off.
192  BOOL_ACCESSOR("geo:skipsaveindex", skipSaveIndex,
193  importSkipSaveIndex, setSkipSaveIndex, false)
194  /// @}
195 
196  /// @{
197  /// When saving geometry, check to see whether we should automatically
198  /// compute normals before saving the geometry. This is used when saving
199  /// geometry to mantra to efficiently compute vertex normals. The value
200  /// should be
201  /// -1 (GA_ATTRIB_INVALID): No automatic export
202  /// 0 (GA_ATTRIB_VERTEX): Compute vertex normals
203  /// 1 (GA_ATTRIB_POINT): Compute point normals
204  INT_ACCESSOR("geo:add_normals_to", addNormalsTo,
205  importAddNormalsTo, setAddNormalsTo, -1)
206  /// @}
207 
208  /// @{
209  /// Specify the LOD for conversion when saving. The value should be
210  /// greater than 0. This may be used when saving to formats which don't
211  /// natively support certain geometry primitives.
212  REAL_ACCESSOR("geo:convert_lod", convertLOD,
213  importConvertLOD, setConvertLOD, 1)
214  /// @}
215 
216 
217  // ----------------------------------------------------------------
218  /// @{
219  /// A debug option used to save internal groups.
220  BOOL_ACCESSOR("group:saveinternal", saveInternal,
221  importSaveInternal, setSaveInternal, false)
222  /// @}
223 
224  /// @{
225  /// A debug option used to save private attributes
226  BOOL_ACCESSOR("geo:ignoreattribscope", ignoreAttribScope,
227  importIgnoreAttribScope, setIgnoreAttribScope, false)
228  /// @}
229 
230 #undef STR_ACCESSOR
231 #undef INT_ACCESSOR
232 #undef REAL_ACCESSOR
233 #undef BOOL_ACCESSOR
234 
235 private:
236 };
237 
238 #endif
const UT_Options & operator=(const UT_Options &src)
Assignment operator.
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
#define GA_API
Definition: GA_API.h:14
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:108
#define STR_ACCESSOR(NAME, GET, IMPORT, SET)
A map of string to various well defined value types.
Definition: UT_Options.h:84
#define BOOL_ACCESSOR(NAME, GET, IMPORT, SET, DEFAULT)
#define REAL_ACCESSOR(NAME, GET, IMPORT, SET, DEFAULT)
#define INT_ACCESSOR(NAME, GET, IMPORT, SET, DEFAULT)
OIIO_UTIL_API std::string extension(string_view filepath, bool include_dot=true) noexcept
GA_SaveOptions & operator=(const UT_Options &opts)