All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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  virtual ~GEO_PrimPasteDAG() {}
34 public:
35  virtual bool isDegenerate() const;
37  virtual 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;
41  virtual bool loadH9(UT_IStream &is,
42  const UT_Array<GA_AttribLoadDataH9> &prim_attribs,
43  const UT_Array<GA_AttribLoadDataH9> &vtx_attribs);
45  bool saveFeatures(UT_JSONWriter &w,
46  const GA_SaveMap &map) const;
47  bool loadFeatures(UT_JSONParser &p,
48  const GA_LoadMap &map);
50  virtual int getBBox(UT_BoundingBox *bbox) const;
51  virtual void addToBSphere(UT_BoundingSphere *bsphere) const;
52  /// @{
53  /// Enlarge a bounding box by the bounding box of the primitive. A
54  /// return value of false indicates an error in the operation, most
55  /// likely an invalid P.
56  virtual bool enlargeBoundingBox(UT_BoundingRect &b,
57  const GA_Attribute *P) const;
58  virtual bool enlargeBoundingBox(UT_BoundingBox &b,
59  const GA_Attribute *P) const;
60  /// @}
61  /// Enlarge a bounding sphere to encompass the primitive. A return value
62  /// of false indicates an error in the operation, most likely an invalid
63  /// P.
65  const GA_Attribute *P) const;
66  virtual UT_Vector3 baryCenter() const;
67  virtual UT_Vector3 computeNormal() const;
68  virtual void reverse();
71  virtual void addPointRefToGroup(GA_PointGroup &grp) const;
72 #endif
73  void addSurfPointRefsToGroup(GA_PointGroup &grp) const;
75  // Take the whole set of points into consideration when applying the
76  // point removal operation to this primitive. The method returns 0 if
77  // successful, -1 if it failed because it would have become degenerate,
78  // and -2 if it failed because it would have had to remove the primitive
79  // altogether.
80  virtual int detachPoints(GA_PointGroup &grp);
82  /// WARNING: This is NOT equivalent to GEO_Primitive::isPointUsed!
83  /// This checks if the GEO_PrimPasteDAG's surfaces use the
84  /// point, whereas GEO_Primitive::isPointUsed does not.
85  bool isPointUsed(GA_Offset ptoff) const;
87  /// Before a point is deleted, all primitives using the point will be
88  /// notified. The method should return "false" if it's impossible to
89  /// delete the point. Otherwise, the vertices should be removed.
90  virtual GA_DereferenceStatus dereferencePoint(GA_Offset point,
91  bool dry_run=false);
92  virtual GA_DereferenceStatus dereferencePoints(
93  const GA_RangeMemberQuery &pt_q,
94  bool dry_run=false);
97  virtual GA_Size getVertexCount() const;
98  virtual GA_Offset getVertexOffset(GA_Size index) const;
100  virtual bool vertexApply(bool (*apply)(GA_Offset vtx, void *),
101  void *data = 0) const;
102 #endif
104  virtual int isPrimary(void) const;
106  virtual void copyPrimitive(const GEO_Primitive *src);
107  virtual GEO_Primitive*copy(int preserve_shared_pts = 0) const;
109  virtual void copyUnwiredForMerge(const GA_Primitive *src,
110  const GA_MergeMap &map);
112  virtual void clearForDeletion();
114  // Convert the real domain values of the primitive to unit values to be
115  // used in the evaluation methods below:
116  virtual void realToUnitPair(float ureal, float vreal,
117  float &uunit, float &vunit) const;
118  // and vice versa
119  virtual void unitToRealPair(float uunit, float vunit,
120  float &ureal, float &vreal) const;
122  virtual int evaluateNormalVector(UT_Vector3 &nml, float u,
123  float v = 0, float w = 0) const;
125  virtual int parametricBBox(float u, float v,
126  float *u0, float *u1,
127  float *v0, float *v1);
129  // Returns distance between two points in parameter space, aware
130  // of any possible wrapping.
131  virtual float uvDist(float u1, float v1, float u2, float v2) const;
133  // Tell the dag it's obsolete. This will happen when the dag has been
134  // pasted onto some other dag, and should be deleted. This method clears
135  // the nodes and deletes "this", so don't use the dag thereafter.
136  virtual void obsolete(void);
138  // Remove all the references to GEO_TPSurf and clear.
139  virtual void isolate(void);
141  // Add all the TPSurfs to the given group. We DON'T CLEAR the group first.
142  void toGroup(GA_PrimitiveGroup &surfgroup) const;
144  // Resolve all the load links: parenting of domains and their frames,
145  // base surfaces, CV displacements, pointers to TPSurf, etc. Return 0
146  // if OK and -1 otherwise. Call this method only after loading the gdp.
147  int resolveLinks(void);
149  // Resolve the remaining copy links, ie. the pointers to the spline
150  // surfaces. What we carry now is the indices of the spline primitives
151  // in the source DAG. Return 0 if all resolved, -1 otherwise.
152  int resolveSplines(const GEO_Detail &srcgdp,
153  const UT_Array<GA_Primitive *> &prim_map);
155  virtual const GA_PrimitiveJSON *getJSON() const;
157  /// Stash (deactivate) or unstash (reactivate) the primitive.
158  virtual void stashed(bool beingstashed,
161 protected:
163  { return GA_FAMILY_NONE; }
165  /// All subclasses should call this method to register the curve intrinsics.
166  /// @see GA_IntrinsicManager
169  { return GEO_Primitive::registerIntrinsics(defn); }
172  /// Defragmentation
173  virtual void swapVertexOffsets(const GA_Defragment &defrag);
174 #endif
176  // Evaluate the position, the derivative or the normal at domain point
177  // (u,v), where u and v MUST be in [0,1]. "v" and "dv" will be ignored
178  // when dealing with one-dimensional types such as circles and polygons.
179  // Return 0 if OK and -1 otherwise. The normal is not normalized.
180  virtual bool evaluatePointRefMap(GA_Offset result,
181  GA_AttributeRefMap &map,
182  fpreal u, fpreal v,
183  unsigned du, unsigned dv) const;
185  virtual int evaluatePointV4( UT_Vector4 &pos, float u, float v = 0,
186  unsigned du=0, unsigned dv=0) const;
187  virtual bool evaluateBaryCenterRefMap(GA_Offset result_vertex,
188  GA_AttributeRefMap &hlist) const;
190 private:
192 };
195 #endif
virtual void copyUnwiredForMerge(const GA_Primitive *src, const GA_MergeMap &map)
Definition of a geometry attribute.
Definition: GA_Attribute.h:189
virtual GEO_Primitive * copy(int preserve_shared_pts=0) const
virtual UT_Vector3 baryCenter() const
virtual void copyPrimitive(const GEO_Primitive *src)=0
virtual void clearForDeletion()
Definition: GA_Primitive.h:598
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:227
const GLdouble * v
Definition: glcorearb.h:836
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
The merge map keeps track of information when merging details.
Definition: GA_MergeMap.h:53
virtual bool enlargeBoundingBox(UT_BoundingRect &b, const GA_Attribute *P) const
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:72
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
Abstract base class for a range membership query object.
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:817
virtual int parametricBBox(float u, float v, float *u0, float *u1, float *v0, float *v1)
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:211
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:654
virtual bool isDegenerate() const =0
Is the primitive degenerate.
GA_Size GA_Offset
Definition: GA_Types.h:617
virtual bool enlargeBoundingSphere(UT_BoundingSphere &b, const GA_Attribute *P) const
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &defn)
virtual const GA_PrimitiveJSON * getJSON() const =0
GLintptr offset
Definition: glcorearb.h:664
Provide a JSON interface to a primitive.
#define GEO_API
Definition: GEO_API.h:10
virtual void reverse()=0
Reverse the order of vertices.
A handle to simplify manipulation of multiple attributes.
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
GLboolean * data
Definition: glcorearb.h:130
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
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
GLfloat v0
Definition: glcorearb.h:815
virtual bool evaluateBaryCenterRefMap(GA_Offset result_vtx, GA_AttributeRefMap &map) const
virtual bool vertexApply(bool(*apply)(GA_Offset vtx, void *), void *data=0) const
double fpreal
Definition: SYS_Types.h:263
bool isPointUsed(GA_Offset ptoff) const
Definition: GA_Primitive.h:309
virtual int detachPoints(GA_PointGroup &grp)=0
GLuint index
Definition: glcorearb.h:785
virtual void unitToRealPair(float uunit, float vunit, float &ureal, float &vreal) const
GLfloat GLfloat v1
Definition: glcorearb.h:816
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:235
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:96
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
virtual ~GEO_PrimPasteDAG()
Definition of a geometric primitive.
bool isPrimary() const
Definition: GA_Primitive.h:160
virtual void obsolete(void)
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)
GLenum src
Definition: glcorearb.h:1792