HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_PrimPasteDAG.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: Paste surface class.
9  *
10  */
11 
12 #ifndef __GEO_PrimPasteDAG_h__
13 #define __GEO_PrimPasteDAG_h__
14 
15 #include "GEO_API.h"
16 #include "GEO_PasteSurfDAG.h"
17 #include "GEO_Primitive.h"
18 
19 class GA_Detail;
20 
22 {
23 protected:
24  /// NOTE: The constructor should only be called from subclass
25  /// constructors.
27  : GEO_Primitive(d, offset)
28  {}
29 
30  /// NOTE: The destructor should only be called from subclass
31  /// destructors.
32  ~GEO_PrimPasteDAG() override {}
33 
34 public:
35  bool isDegenerate() const override;
36 
37  bool saveH9(std::ostream &os, bool binary,
38  const UT_Array<GA_AttribSaveDataH9> &prim_attribs,
39  const UT_Array<GA_AttribSaveDataH9> &vtx_attribs
40  ) const override;
41  bool loadH9(UT_IStream &is,
42  const UT_Array<GA_AttribLoadDataH9> &prim_attribs,
43  const UT_Array<GA_AttribLoadDataH9> &vtx_attribs
44  ) override;
45 
46  bool saveFeatures(UT_JSONWriter &w,
47  const GA_SaveMap &map) const;
48  bool loadFeatures(UT_JSONParser &p,
49  const GA_LoadMap &map);
50 
51  int getBBox(UT_BoundingBox *bbox) const override;
52  void addToBSphere(
53  UT_BoundingSphere *bsphere) const override;
54  /// @{
55  /// Enlarge a bounding box by the bounding box of the primitive. A
56  /// return value of false indicates an error in the operation, most
57  /// likely an invalid P.
58  bool enlargeBoundingBox(
60  const GA_Attribute *P) const override;
61  bool enlargeBoundingBox(
63  const GA_Attribute *P) const override;
64  /// @}
65  /// Enlarge a bounding sphere to encompass the primitive. A return value
66  /// of false indicates an error in the operation, most likely an invalid
67  /// P.
70  const GA_Attribute *P) const override;
71  UT_Vector3 baryCenter() const override;
72  UT_Vector3 computeNormal() const override;
73  void reverse() override;
74 
75 #if !GA_PRIMITIVE_VERTEXLIST
76  virtual void addPointRefToGroup(GA_PointGroup &grp) const;
77 #endif
78  void addSurfPointRefsToGroup(GA_PointGroup &grp) const;
79 
80  // Take the whole set of points into consideration when applying the
81  // point removal operation to this primitive. The method returns 0 if
82  // successful, -1 if it failed because it would have become degenerate,
83  // and -2 if it failed because it would have had to remove the primitive
84  // altogether.
85  int detachPoints(GA_PointGroup &grp) override;
86 
87  /// WARNING: This is NOT equivalent to GEO_Primitive::isPointUsed!
88  /// This checks if the GEO_PrimPasteDAG's surfaces use the
89  /// point, whereas GEO_Primitive::isPointUsed does not.
90  bool isPointUsed(GA_Offset ptoff) const;
91 
92  /// Before a point is deleted, all primitives using the point will be
93  /// notified. The method should return "false" if it's impossible to
94  /// delete the point. Otherwise, the vertices should be removed.
95  GA_DereferenceStatus dereferencePoint(GA_Offset point,
96  bool dry_run=false) override;
97  GA_DereferenceStatus dereferencePoints(const GA_RangeMemberQuery &pt_q,
98  bool dry_run=false) override;
99 
100 #if !GA_PRIMITIVE_VERTEXLIST
101  virtual GA_Size getVertexCount() const;
102  virtual GA_Offset getVertexOffset(GA_Size index) const;
103 
104  virtual bool vertexApply(bool (*apply)(GA_Offset vtx, void *),
105  void *data = 0) const;
106 #endif
107 
108  virtual int isPrimary() const;
109 
110  void copyPrimitive(const GEO_Primitive *src) override;
111  GEO_Primitive *copy(int preserve_shared_pts = 0) const override;
112 
113  void copySubclassData(const GA_Primitive *source) override;
114 
115  void clearForDeletion() override;
116 
117  // Convert the real domain values of the primitive to unit values to be
118  // used in the evaluation methods below:
119  void realToUnitPair(
120  float ureal, float vreal,
121  float &uunit, float &vunit) const override;
122  // and vice versa
123  void unitToRealPair(
124  float uunit, float vunit,
125  float &ureal, float &vreal) const override;
126 
128  UT_Vector3 &nml, float u,
129  float v = 0, float w = 0) const override;
130 
131  int parametricBBox(float u, float v,
132  float *u0, float *u1,
133  float *v0, float *v1) override;
134 
135  // Returns distance between two points in parameter space, aware
136  // of any possible wrapping.
137  float uvDist(float u1, float v1,
138  float u2, float v2) const override;
139 
140  // Tell the dag it's obsolete. This will happen when the dag has been
141  // pasted onto some other dag, and should be deleted. This method clears
142  // the nodes and deletes "this", so don't use the dag thereafter.
143  void obsolete() override;
144 
145  // Remove all the references to GEO_TPSurf and clear.
146  void isolate() override;
147 
148  // Add all the TPSurfs to the given group. We DON'T CLEAR the group first.
149  void toGroup(GA_PrimitiveGroup &surfgroup) const;
150 
151  // Resolve all the load links: parenting of domains and their frames,
152  // base surfaces, CV displacements, pointers to TPSurf, etc. Return 0
153  // if OK and -1 otherwise. Call this method only after loading the gdp.
154  int resolveLinks();
155 
156  // Resolve the remaining copy links, ie. the pointers to the spline
157  // surfaces. What we carry now is the indices of the spline primitives
158  // in the source DAG. Return 0 if all resolved, -1 otherwise.
159  int resolveSplines(const GEO_Detail &srcgdp,
160  const UT_Array<GA_Primitive *> &prim_map);
161 
162  const GA_PrimitiveJSON *getJSON() const override;
163 
164  /// Stash (deactivate) or unstash (reactivate) the primitive.
165  void stashed(bool beingstashed,
166  GA_Offset offset = GA_INVALID_OFFSET) override;
167 
168 protected:
170  { return GA_FAMILY_NONE; }
171 
172  /// All subclasses should call this method to register the curve intrinsics.
173  /// @see GA_IntrinsicManager
176  { return GEO_Primitive::registerIntrinsics(defn); }
177 
178 #if !GA_PRIMITIVE_VERTEXLIST
179  /// Defragmentation
180  virtual void swapVertexOffsets(const GA_Defragment &defrag);
181 #endif
182 
183  // Evaluate the position, the derivative or the normal at domain point
184  // (u,v), where u and v MUST be in [0,1]. "v" and "dv" will be ignored
185  // when dealing with one-dimensional types such as circles and polygons.
186  // Return 0 if OK and -1 otherwise. The normal is not normalized.
187  bool evaluatePointRefMap(
189  GA_AttributeRefMap &map,
190  fpreal u, fpreal v,
191  unsigned du, unsigned dv) const override;
192 
193  int evaluatePointV4(
194  UT_Vector4 &pos,
195  float u, float v = 0,
196  unsigned du=0, unsigned dv=0) const override;
198  GA_Offset result_vertex,
199  GA_AttributeRefMap &hlist) const override;
200 
201 private:
203 };
205 
206 #endif
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
Definition of a geometry attribute.
Definition: GA_Attribute.h:196
virtual UT_Vector3 baryCenter() const
virtual void copyPrimitive(const GEO_Primitive *src)=0
virtual void clearForDeletion()
Definition: GA_Primitive.h:658
Used to pass options and map offset values during saving.
Definition: GA_SaveMap.h:48
SYS_FORCE_INLINE GA_Size getVertexCount() const
Return the number of vertices used by this primitive.
Definition: GA_Primitive.h:232
#define SYS_DEPRECATED_PUSH_DISABLE()
#define SYS_DEPRECATED_POP_DISABLE()
virtual void copySubclassData(const GA_Primitive *source)
Definition: GA_Primitive.h:484
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
void reverse(I begin, I end)
Definition: pugixml.cpp:7190
~GEO_PrimPasteDAG() override
virtual GA_DereferenceStatus dereferencePoint(GA_Offset point, bool dry_run=false)=0
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:88
bool enlargeBoundingBox(UT_BoundingRect &b, const GA_Attribute *P) const override
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:35
Abstract base class for a range membership query object.
GLuint GLdouble u1
Definition: glew.h:3460
virtual int parametricBBox(float u, float v, float *u0, float *u1, float *v0, float *v1)
GLenum src
Definition: glcorearb.h:1792
3D Vector class.
static GA_PrimitiveFamilyMask buildFamilyMask()
virtual void realToUnitPair(float ureal, float vreal, float &uunit, float &vunit) const
virtual void swapVertexOffsets(const GA_Defragment &defrag)
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:234
virtual bool loadH9(UT_IStream &is, const UT_Array< GA_AttribLoadDataH9 > &prim_attribs, const UT_Array< GA_AttribLoadDataH9 > &vtx_attribs)
GA_PrimitiveFamilyMask
virtual UT_Vector3 computeNormal() const =0
Return a normal vector for the primitive.
#define GA_INVALID_OFFSET
Definition: GA_Types.h:677
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
virtual bool isDegenerate() const =0
Is the primitive degenerate.
GA_Size GA_Offset
Definition: GA_Types.h:640
virtual bool enlargeBoundingSphere(UT_BoundingSphere &b, const GA_Attribute *P) const
virtual void obsolete()
GLuint64EXT * result
Definition: glew.h:14311
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:817
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &defn)
const GLdouble * v
Definition: glcorearb.h:836
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:802
virtual const GA_PrimitiveJSON * getJSON() const =0
Provide a JSON interface to a primitive.
#define GEO_API
Definition: GEO_API.h:14
A handle to simplify manipulation of multiple attributes.
GLfloat GLfloat p
Definition: glew.h:16656
Options during loading.
Definition: GA_LoadMap.h:42
virtual int getBBox(UT_BoundingBox *bbox) const =0
virtual float uvDist(float u1, float v1, float u2, float v2) const
Defragmentation of IndexMaps.
Definition: GA_Defragment.h:45
void addPointRefToGroup(GA_PointGroup &grp) const
GLfloat v0
Definition: glcorearb.h:815
virtual GA_DereferenceStatus dereferencePoints(const GA_RangeMemberQuery &pt_q, bool dry_run=false)=0
virtual bool saveH9(std::ostream &os, bool binary, const UT_Array< GA_AttribSaveDataH9 > &prim_attribs, const UT_Array< GA_AttribSaveDataH9 > &vtx_attribs) const
virtual bool evaluateBaryCenterRefMap(GA_Offset result_vtx, GA_AttributeRefMap &map) const
GLboolean * data
Definition: glcorearb.h:130
virtual bool vertexApply(bool(*apply)(GA_Offset vtx, void *), void *data=0) const
bool isPointUsed(GA_Offset ptoff) const
Definition: GA_Primitive.h:314
virtual int detachPoints(GA_PointGroup &grp)=0
fpreal64 fpreal
Definition: SYS_Types.h:277
GLuint index
Definition: glcorearb.h:785
virtual void unitToRealPair(float uunit, float vunit, float &ureal, float &vreal) const
OIIO_API bool copy(string_view from, string_view to, std::string &err)
virtual int evaluateNormalVector(UT_Vector3 &nml, float u, float v=0, float w=0) const
SYS_FORCE_INLINE GA_Offset getVertexOffset(GA_Size primvertexnum) const
Definition: GA_Primitive.h:240
virtual bool evaluatePointRefMap(GA_Offset result_vtx, GA_AttributeRefMap &map, fpreal u, fpreal v=0, uint du=0, uint dv=0) const =0
virtual void addToBSphere(UT_BoundingSphere *bsphere) const
Container class for all geometry.
Definition: GA_Detail.h:95
GLintptr offset
Definition: glcorearb.h:664
Definition of a geometric primitive.
GLfloat GLfloat v1
Definition: glcorearb.h:816
bool isPrimary() const
Definition: GA_Primitive.h:169
GLuint GLdouble GLdouble u2
Definition: glew.h:3460
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &defn)
virtual void isolate()
Method to isolate a pasted surface.
virtual int evaluatePointV4(UT_Vector4 &pos, float u, float v=0, unsigned du=0, unsigned dv=0) const
virtual void stashed(bool beingstashed, GA_Offset offset=GA_INVALID_OFFSET)
GEO_PrimPasteDAG(GA_Detail *d, GA_Offset offset=GA_INVALID_OFFSET)