HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GEO_PrimMesh.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:
9  * This class is a subclass of the GEO_Hull class. It represents
10  * a linear patch (i.e. non-interpolating)
11  *
12  */
13 
14 #ifndef __GEO_PrimMesh_h__
15 #define __GEO_PrimMesh_h__
16 
17 #include "GEO_API.h"
18 #include "GEO_Hull.h"
19 #include "GEO_PrimType.h"
20 
21 class GA_Detail;
22 
24 {
25 protected:
26  /// NOTE: The constructor should only be called from subclass
27  /// constructors.
29  : GEO_Hull(d, offset)
30  {}
31 
32  /// NOTE: The destructor should only be called from subclass
33  /// destructors.
34  virtual ~GEO_PrimMesh() {}
35 
36 public:
37  // Compute the location of the breakpoint. Return 0 if OK, else -1.
38  virtual int evaluateBreakpoint(int uidx, int vidx,
39  UT_Vector4 &pos,
40  int du=0, int dv=0) const;
41 
42  // Raise the number of CVs to match the newcount. The shape of the face
43  // (especially if parametric) should NOT change. Return 0 upon success
44  // and -1 otherwise. start and stop define which indices to examine
45  // if newcount is negative it is taken as a relative value.
46  virtual int loftU(int newcount, int start=-1, int stop=-1);
47  virtual int loftV(int newcount, int start=-1, int stop=-1);
48 
49  // Warp the mesh at u,v by the given delta. Change 1 or 4 Cvs and possibly
50  // insert a knot once or more as well. If a knot is inserted or we happen
51  // to land exactly on a knot, we change only one CV. The bias makes sense
52  // only when changing 4 CVs, and will be ignored altogether if < 0.
53  // We return the CV index in warpU/V and 0 in warp() if OK; -1 otherwise.
54  virtual int warpU(float u, const UT_Vector3 &delta,
55  GA_AttributeRefMap &map,
56  float sharpness = 0.0f, float bias = -1.0f);
57  virtual int warpV(float v, const UT_Vector3 &delta,
58  GA_AttributeRefMap &map,
59  float sharpness = 0.0f, float bias = -1.0f);
60  virtual int warp (float u, float v, const UT_Vector3 &delta,
61  GA_AttributeRefMap &map,
62  float usharpness = 0.f, float vsharpness = 0.f,
63  float ubias = -1.0f, float vbias = -1.0f);
64 
65  // Append another hull to us in one of two ways: blend the two endpoints
66  // or connect them straight or rounded. The bias ranges from 0 to 1 and is
67  // relevant only to blending. The tolerance for blending: if 0, the two
68  // endpoints will merge into one point with a discontinuity; if less than
69  // 1, we insert knots into the hulls to minimize the affected areas; if 1,
70  // no refinement is done. For the non-blend case, the tolerance will
71  // generate a span whose shape goes from round to straight; 0 tolerance
72  // means straight connection. If unrefine is on, we'll try to reduce the
73  // complexity of the hull if we're connecting rounded. We return 0 if OK
74  // and -1 if error. Both hulls must be open and have the same order.
75  virtual int attachU(const GEO_Hull &hull, int blend = 1,
76  float bias = 0.5f, float tolerance = 1.0f,
77  int= 1,GA_PointGroup *ptgroup=0);
78  virtual int attachV(const GEO_Hull &hull, int blend = 1,
79  float bias = 0.5f, float tolerance = 1.0f,
80  int= 1,GA_PointGroup *ptgroup=0);
81 
82  virtual int unrollU(int append_pts = 1);
83  virtual int unrollV(int append_pts = 1);
84 
85  virtual const GA_PrimitiveJSON *getJSON() const;
86 
87 protected:
89  { return GEO_Hull::buildFamilyMask(); }
90 
91  /// All subclasses should call this method to register the mesh intrinsics.
92  /// @see GA_IntrinsicManager
95  { return GEO_Hull::registerIntrinsics(defn); }
96 
97  virtual bool savePrivateH9(std::ostream &, bool binary) const;
98  virtual bool loadPrivateH9(UT_IStream &);
99  virtual bool saveExtraH9 (std::ostream &, bool binary) const;
100  virtual bool loadExtraH9 (UT_IStream &);
101 
102  // Check the validity of the data. Meant to be called especially at loading
103  // time. The method returns 1 if OK and 0 if trouble.
104  virtual bool validate(void) const;
105 
106  // Return the squared max distance between any two successive vertices
107  // and the index of the "left" vertex. If the polygon is closed we
108  // compare the 1st and last vertices as well and if their distance is the
109  // largest, we return the index of the last vertex.
110  int findMaxDistanceU(float &maxdist2,
111  int start, int stop) const;
112 
113  int findMaxDistanceV(float &maxdist2,
114  int start, int stop) const;
115 
116  // Evaluate the position or the derivative at unit domain point
117  // (u,v), where u and v MUST be in [0,1]. Return 0 if OK and -1 otherwise.
118  // The normal is not normalized.
119  virtual bool evaluatePointRefMap( GA_Offset result,
120  GA_AttributeRefMap &map,
121  fpreal u, fpreal v,
122  unsigned du=0, unsigned dv=0) const;
123  virtual int evaluatePointV4( UT_Vector4 &pos, float u, float v = 0,
124  unsigned du=0, unsigned dv=0) const;
125 
126  // Refine for all spans with specified number of divisions per span.
127  virtual void spanRefineURefMap(GA_AttributeRefMap &map,
128  int numdivs=1);
129  virtual void spanRefineUInt(int numdivs=1);
130  virtual void spanRefineVRefMap(GA_AttributeRefMap &map,
131  int numdivs=1);
132  virtual void spanRefineVInt(int numdivs=1);
133 
134 private:
135  friend std::ostream &operator<<(std::ostream &os, const GEO_PrimMesh &d)
136  {
137  d.saveH9(os, 0,
140  return os;
141  }
142 };
143 #endif
virtual int loftV(int newcount, int start=-1, int stop=-1)=0
GEO_PrimMesh(GA_Detail *d, GA_Offset offset=GA_INVALID_OFFSET)
Definition: GEO_PrimMesh.h:28
virtual int unrollU(int append_pts=1)
virtual int evaluateBreakpoint(int uidx, int vidx, UT_Vector4 &pos, int du=0, int dv=0) const =0
virtual int attachV(const GEO_Hull &hull, int blend=1, float bias=0.5f, float tolerance=1.0f, int unrefine=1, GA_PointGroup *ptgroup=0)=0
virtual ~GEO_PrimMesh()
Definition: GEO_PrimMesh.h:34
const GLdouble * v
Definition: glcorearb.h:836
GLuint start
Definition: glcorearb.h:474
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
static GA_PrimitiveFamilyMask buildFamilyMask()
Definition: GEO_Hull.h:665
virtual int warp(float u, float v, const UT_Vector3 &delta, GA_AttributeRefMap &map, float usharpness=0.0f, float vsharpness=0.f, float ubias=-1.0f, float vbias=-1.0f)=0
virtual int warpU(float u, const UT_Vector3 &delta, GA_AttributeRefMap &map, float sharpness=0.0f, float bias=-1.0f)=0
3D Vector class.
virtual void spanRefineURefMap(GA_AttributeRefMap &map, int numdivs=1)=0
GA_PrimitiveFamilyMask
bool saveH9(std::ostream &os, bool binary, const UT_Array< GA_AttribSaveDataH9 > &prim_attribs, const UT_Array< GA_AttribSaveDataH9 > &vtx_attribs) const override
#define GA_INVALID_OFFSET
Definition: GA_Types.h:654
virtual int warpV(float v, const UT_Vector3 &delta, GA_AttributeRefMap &map, float sharpness=0.0f, float bias=-1.0f)=0
GA_Size GA_Offset
Definition: GA_Types.h:617
GLfloat f
Definition: glcorearb.h:1925
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
A handle to simplify manipulation of multiple attributes.
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &defn)
Definition: GEO_PrimMesh.h:94
static GA_PrimitiveFamilyMask buildFamilyMask()
Definition: GEO_PrimMesh.h:88
double fpreal
Definition: SYS_Types.h:269
virtual void spanRefineUInt(int numdivs=1)=0
static const UT_Array< GA_AttribSaveDataH9 > & theEmptySaveAttribs
Convience objects to pass as arguments to saveH9()/loadH9().
virtual bool loadExtraH9(UT_IStream &is)=0
virtual int loftU(int newcount, int start=-1, int stop=-1)=0
friend std::ostream & operator<<(std::ostream &os, const GEO_PrimMesh &d)
Definition: GEO_PrimMesh.h:135
virtual bool evaluatePointRefMap(GA_Offset result_vtx, GA_AttributeRefMap &map, fpreal u, fpreal v=0, uint du=0, uint dv=0) const =0
virtual bool loadPrivateH9(UT_IStream &is)=0
Container class for all geometry.
Definition: GA_Detail.h:96
virtual void spanRefineVRefMap(GA_AttributeRefMap &map, int numdivs=1)=0
Definition of a geometric primitive.
virtual int attachU(const GEO_Hull &hull, int blend=1, float bias=0.5f, float tolerance=1.0f, int unrefine=1, GA_PointGroup *ptgroup=0)=0
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &defn)
virtual bool saveExtraH9(std::ostream &os, bool binary) const =0
virtual bool savePrivateH9(std::ostream &os, bool binary) const =0
virtual void spanRefineVInt(int numdivs=1)=0
virtual int evaluatePointV4(UT_Vector4 &pos, float u, float v=0, unsigned du=0, unsigned dv=0) const
virtual bool validate(void) const =0
virtual int unrollV(int append_pts=1)