All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  */
12 #ifndef __GEO_PrimPasteDAG_h__
13 #define __GEO_PrimPasteDAG_h__
15 #include "GEO_API.h"
16 #include "GEO_PasteSurfDAG.h"
17 #include "GEO_Primitive.h"
19 class GA_Detail;
22 {
23 protected:
24  /// NOTE: The constructor should only be called from subclass
25  /// constructors.
27  : GEO_Primitive(d, offset)
28  {}
30  /// NOTE: The destructor should only be called from subclass
31  /// destructors.
32  ~GEO_PrimPasteDAG() override {}
34 public:
35  bool isDegenerate() const override;
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;
46  bool saveFeatures(UT_JSONWriter &w,
47  const GA_SaveMap &map) const;
48  bool loadFeatures(UT_JSONParser &p,
49  const GA_LoadMap &map);
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;
76  virtual void addPointRefToGroup(GA_PointGroup &grp) const;
77 #endif
78  void addSurfPointRefsToGroup(GA_PointGroup &grp) const;
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;
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;
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;
101  virtual GA_Size getVertexCount() const;
102  virtual GA_Offset getVertexOffset(GA_Size index) const;
104  virtual bool vertexApply(bool (*apply)(GA_Offset vtx, void *),
105  void *data = 0) const;
106 #endif
108  virtual int isPrimary() const;
110  void copyPrimitive(const GEO_Primitive *src) override;
111  GEO_Primitive *copy(int preserve_shared_pts = 0) const override;
113  void copySubclassData(const GA_Primitive *source) override;
115  void clearForDeletion() override;
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;
128  UT_Vector3 &nml, float u,
129  float v = 0, float w = 0) const override;
131  int parametricBBox(float u, float v,
132  float *u0, float *u1,
133  float *v0, float *v1) override;
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;
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;
145  // Remove all the references to GEO_TPSurf and clear.
146  void isolate() override;
148  // Add all the TPSurfs to the given group. We DON'T CLEAR the group first.
149  void toGroup(GA_PrimitiveGroup &surfgroup) const;
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();
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);
162  const GA_PrimitiveJSON *getJSON() const override;
164  /// Stash (deactivate) or unstash (reactivate) the primitive.
165  void stashed(bool beingstashed,
166  GA_Offset offset = GA_INVALID_OFFSET) override;
168 protected:
170  { return GA_FAMILY_NONE; }
172  /// All subclasses should call this method to register the curve intrinsics.
173  /// @see GA_IntrinsicManager
176  { return GEO_Primitive::registerIntrinsics(defn); }
179  /// Defragmentation
180  virtual void swapVertexOffsets(const GA_Defragment &defrag);
181 #endif
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;
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;
201 private:
203 };
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
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)
virtual UT_Vector3 computeNormal() const =0
Return a normal vector for the primitive.
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)