HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_ElementSetMap.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: GT_ElementSetMap.h (GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_ElementSetMap__
12 #define __GT_ElementSetMap__
13 
14 #include "GT_API.h"
15 
16 #include <UT/UT_StringMap.h>
17 #include <UT/UT_IntrusivePtr.h>
18 #include <UT/UT_Set.h>
19 #include "GT_ElementSet.h"
20 
21 class UT_JSONWriter;
22 class GT_ElementSetMap;
23 
25 
26 /// Class to store sets of faces / points / etc on GT mesh primitives
27 class GT_API GT_ElementSetMap : public UT_IntrusiveRefCounter<GT_ElementSetMap>
28 {
29 public:
31 
34 
36 
37  /// @{
38  /// Map access. These methods are @b not thread-safe
39  GT_ElementSetPtr find(const UT_StringRef &name) const;
41  const GT_ElementSetPtr &set,
42  bool replace_existing=true);
43  GT_Size entries() const { return myMap.size(); }
44  /// @}
45 
46  /// Save sets to a JSON stream
47  bool save(UT_JSONWriter &w) const;
48  void dump() const;
49 
51  {
52  public:
54  iterator() = default;
55 
56  const UT_StringHolder &name() const { return myIt->first; }
57  const GT_ElementSetPtr &subset() const { return myIt->second; }
58  /// Alias for backwards compatibility with GT_FaceSet.
59  const GT_ElementSetPtr &faceSet() const { return myIt->second; }
60 
61  iterator &operator++() { ++myIt; return *this; }
63  {
64  myIt = src.myIt;
65  myEnd = src.myEnd;
66  return *this;
67  }
68  bool operator==(const iterator &cmp) const
69  { return myIt == cmp.myIt; }
70  bool operator!=(const iterator &cmp) const
71  { return myIt != cmp.myIt; }
72  bool atEnd() const { return myIt == myEnd; }
73  void advance() { ++myIt; }
74  private:
75  iterator(const MapIterator &it, const MapIterator &end)
76  : myIt(it)
77  , myEnd(end)
78  {
79  }
80  MapIterator myIt;
81  MapIterator myEnd;
82  friend class GT_ElementSetMap;
83  };
84  iterator begin() const { return iterator(myMap.begin(), myMap.end()); }
85  iterator end() const { return iterator(myMap.end(), myMap.end()); }
86 
87  /// Delete elements from the sets. The second argument is an array
88  /// mapping the old element numbers to the new element numbers. For example,
89  /// deleting polygon 2 from a set of [0,1,2,3] would expect a remapping
90  /// array of [0,1,x,2] (the value of 2 doesn't actually matter)
92  const GT_Int32Array &mapping) const;
93 
94  /// Delete polygons from the face set. The second argument is an array
95  /// mapping the old face numbers to the new face numbers. For example,
96  /// deleting polygon 2 from a set of [0,1,2,3] would expect a remapping
97  /// array of [0,1,x,2] (the value of 2 doesn't actually matter)
98  SYS_DEPRECATED_REPLACE(20.5, "deleteElements")
99  GT_FaceSetMapPtr deleteFaces(const UT_Set<int> &faces,
100  const GT_Int32Array &mapping) const
101  { return deleteElements(faces, mapping); }
102 
103 
104  exint getMemoryUsage() const;
105 
106 private:
107  MapType myMap;
108 };
109 
110 #endif
GT_Size entries() const
const GT_ElementSetPtr & faceSet() const
Alias for backwards compatibility with GT_FaceSet.
iterator & operator=(const iterator &src)
GT_ElementSetMap::MapType::const_iterator MapIterator
const GT_ElementSetPtr & subset() const
#define GT_API
Definition: GT_API.h:13
int64 exint
Definition: SYS_Types.h:125
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
A reference counter base class for use with UT_IntrusivePtr.
IMATH_HOSTDEVICE constexpr int cmp(T a, T b) IMATH_NOEXCEPT
Definition: ImathFun.h:84
#define SYS_DEPRECATED_REPLACE(__V__, __R__)
GLuint GLuint end
Definition: glcorearb.h:475
GT_ElementSetMapPtr deleteElements(const UT_Set< int > &elements, const GT_Int32Array &mapping) const
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
bool operator==(const iterator &cmp) const
const UT_StringHolder & name() const
Class to store sets of faces / points / etc on GT mesh primitives.
GLuint const GLchar * name
Definition: glcorearb.h:786
Parent::const_iterator const_iterator
Definition: UT_StringMap.h:51
exint getMemoryUsage() const
iterator end() const
iterator begin() const
int64 GT_Size
Definition: GT_Types.h:128
bool operator!=(const iterator &cmp) const
An array of numeric values (int32, int64, fpreal16, fpreal32, fpreal64)
Definition: GT_DANumeric.h:23
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
ImageBuf OIIO_API add(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
UT_StringMap< GT_ElementSetPtr > MapType
GT_FaceSetMapPtr deleteFaces(const UT_Set< int > &faces, const GT_Int32Array &mapping) const
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
Definition: core.h:2089
GLenum src
Definition: glcorearb.h:1793