HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GD_TrimRegion.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: Geometry library (C++)
7  *
8  * COMMENTS: This is the trimming region class.
9  *
10  */
11 
12 #ifndef __GD_TrimRegion_h__
13 #define __GD_TrimRegion_h__
14 
15 #include "GD_API.h"
16 #include <GA/GA_Types.h>
17 #include <UT/UT_LinkList.h>
18 #include <UT/UT_BoundingRect.h>
19 #include <SYS/SYS_Math.h>
20 
21 class UT_IStream;
22 class GA_PrimitiveGroup;
23 class GD_Detail;
24 class GD_Face;
25 class GD_Primitive;
26 class GD_TrimLoop;
27 class GA_LoadMap;
28 class GA_SaveMap;
29 
31 {
32 public:
33  GD_TrimFace(GD_Face &face, float ustart, float ustop) : myFace(face)
34  {
35  myUstart = ustart;
36  myUstop = ustop;
37  }
38  virtual ~GD_TrimFace();
39 
40  const GD_Face &face (void) const { return myFace; }
41  float uStop (void) const { return myUstop; }
42  float uStart(void) const { return myUstart; }
43 
44  int operator==(const GD_TrimFace &tface) const
45  {
46  return (&myFace == &tface.myFace ) &&
47  SYSisEqual( myUstart, tface.myUstart) &&
48  SYSisEqual( myUstop, tface.myUstop );
49  }
50 
51  void reverse();
52  GD_TrimLoop *buildLoop(void) const;
53 
54  int save(std::ostream &os, int binary) const;
55  bool jsonSave(UT_JSONWriter &w, const GA_SaveMap &map) const;
56 
57  // Load information for a face from a JSON file.
58  static bool jsonLoad(UT_JSONParser &p, const GA_LoadMap &map,
59  GA_Offset &face_offset, fpreal &u0, fpreal &u1);
60 
61 private:
62  GD_Face &myFace;
63  float myUstart;
64  float myUstop;
65 };
66 
67 
69 {
70 public:
71  GD_TrimRegionFlags() { dirty = 1; opencasual = 0; domainclipped=0; }
72  unsigned opencasual:1,
73  dirty:1,
74  domainclipped:1;
75 };
76 
77 
79 {
80 public:
81  GD_TrimRegion(int opencasual = 0); // keep direction of open faces
82  virtual ~GD_TrimRegion();
83 
84  virtual int64 getMemoryUsage(bool inclusive) const;
85 
86  // Reverse the order of the trim faces in the region
87  virtual void reverse(void);
88 
89  // Find out about our flags:
90  int isDirty(void) const { return myFlags.dirty; }
91  int isOpenCasual()const { return myFlags.opencasual; }
92  int isValid(void) const { return myLoop &&
93  !myFlags.dirty; }
94 
95  int getNum (void) const { return myNum; }
96 
97  // Grab a handle to the loop of curve pieces. The non-const method
98  // builds it if necessary.
99  const GD_TrimLoop *getLoop(void) const { return myLoop; }
100  GD_TrimLoop *getLoop(const UT_BoundingRect &brect,
101  float tolerance = 1e-4F,
102  int doDomainClip = 1);
103 
104  // Find out if the region contains the given primitive or any primitive
105  // in the group:
106  int contains(const GD_Primitive &prim ) const;
107  int contains(const GA_PrimitiveGroup &group,
108  int count_how_many = 0 ) const;
109 
110  // Returns the number of GD_TrimFaces removed or 0 if none.
111  int remove(const GD_Primitive &prim );
112  int remove(const GA_PrimitiveGroup &group);
113 
114  // Merges into the given group all faces inside this trimregion:
115  void merge(GA_PrimitiveGroup *group) const;
116 
117  // Copy from source. Return 0 if OK and -1 otherwise.
118  int copy(GD_Detail &gdp, const GD_TrimRegion &src,
119  int primoffset);
120 
121  // I/O stuff:
122  bool load(GD_Detail &gdp, UT_IStream &is);
123  int save(std::ostream &os, int binary) const;
124 
125 
126  /// @{
127  /// JSON IO
128  ///
129  bool jsonLoad(GD_Detail &gdp, UT_JSONParser &p, const GA_LoadMap &map);
130  bool jsonSave(UT_JSONWriter &w, const GA_SaveMap &map) const;
131  /// @}
132 
133 protected:
134  void setNum(int num) { myNum = num; }
135  void initialize(void);
136 
137 private:
138  int myNum; // Only the detail can set this...
139  GD_TrimRegionFlags myFlags;
140  GD_TrimLoop *myLoop;
141 
142  friend class GD_Detail;
143 };
144 
145 #endif
const GD_Face & face(void) const
Definition: GD_TrimRegion.h:40
float uStop(void) const
Definition: GD_TrimRegion.h:41
Used to pass options and map offset values during saving.
Definition: GA_SaveMap.h:48
float uStart(void) const
Definition: GD_TrimRegion.h:42
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
int isValid(void) const
Definition: GD_TrimRegion.h:92
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:72
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
GA_Size GA_Offset
Definition: GA_Types.h:617
const GD_TrimLoop * getLoop(void) const
Definition: GD_TrimRegion.h:99
long long int64
Definition: SYS_Types.h:100
int operator==(const GD_TrimFace &tface) const
Definition: GD_TrimRegion.h:44
Options during loading.
Definition: GA_LoadMap.h:42
int getNum(void) const
Definition: GD_TrimRegion.h:95
GD_TrimFace(GD_Face &face, float ustart, float ustop)
Definition: GD_TrimRegion.h:33
OPENVDB_API void initialize()
Global registration of basic types.
Definition: logging.h:316
double fpreal
Definition: SYS_Types.h:263
#define GD_API
Definition: GD_API.h:10
void setNum(int num)
png_infop png_uint_32 int num
Definition: png.h:2158
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
int isOpenCasual() const
Definition: GD_TrimRegion.h:91
int isDirty(void) const
Definition: GD_TrimRegion.h:90
GLenum src
Definition: glcorearb.h:1792