HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  ~GEO_PrimMesh() override {}
35 
36 public:
37  // Compute the location of the breakpoint. Return 0 if OK, else -1.
38  int evaluateBreakpoint(int uidx, int vidx,
39  UT_Vector4 &pos,
40  int du=0, int dv=0) const override;
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  int loftU(int newcount, int start=-1, int stop=-1) override;
47  int loftV(int newcount, int start=-1, int stop=-1) override;
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  int warpU(float u,
55  const UT_Vector3 &delta,
56  GA_AttributeRefMap &map,
57  float sharpness = 0.0f,
58  float bias = -1.0f) override;
59  int warpV(float v,
60  const UT_Vector3 &delta,
61  GA_AttributeRefMap &map,
62  float sharpness = 0.0f,
63  float bias = -1.0f) override;
64  int warp(float u, float v,
65  const UT_Vector3 &delta,
66  GA_AttributeRefMap &map,
67  float usharpness = 0.f, float vsharpness = 0.f,
68  float ubias = -1.0f, float vbias = -1.0f
69  ) override;
70 
71  // Append another hull to us in one of two ways: blend the two endpoints
72  // or connect them straight or rounded. The bias ranges from 0 to 1 and is
73  // relevant only to blending. The tolerance for blending: if 0, the two
74  // endpoints will merge into one point with a discontinuity; if less than
75  // 1, we insert knots into the hulls to minimize the affected areas; if 1,
76  // no refinement is done. For the non-blend case, the tolerance will
77  // generate a span whose shape goes from round to straight; 0 tolerance
78  // means straight connection. If unrefine is on, we'll try to reduce the
79  // complexity of the hull if we're connecting rounded. We return 0 if OK
80  // and -1 if error. Both hulls must be open and have the same order.
81  int attachU(const GEO_Hull &hull, int blend = 1,
82  float bias = 0.5f, float tolerance = 1.0f,
83  int= 1,GA_PointGroup *ptgroup=0) override;
84  int attachV(const GEO_Hull &hull, int blend = 1,
85  float bias = 0.5f, float tolerance = 1.0f,
86  int= 1,GA_PointGroup *ptgroup=0) override;
87 
88  int unrollU(int append_pts = 1) override;
89  int unrollV(int append_pts = 1) override;
90 
91  const GA_PrimitiveJSON *getJSON() const override;
92 
93 protected:
95  { return GEO_Hull::buildFamilyMask(); }
96 
97  /// All subclasses should call this method to register the mesh intrinsics.
98  /// @see GA_IntrinsicManager
101  { return GEO_Hull::registerIntrinsics(defn); }
102 
103  bool savePrivateH9(std::ostream &,
104  bool binary) const override;
105  bool loadPrivateH9(UT_IStream &) override;
106  bool saveExtraH9(std::ostream &, bool binary) const override;
107  bool loadExtraH9(UT_IStream &) override;
108 
109  // Check the validity of the data. Meant to be called especially at loading
110  // time. The method returns 1 if OK and 0 if trouble.
111  bool validate() const override;
112 
113  // Return the squared max distance between any two successive vertices
114  // and the index of the "left" vertex. If the polygon is closed we
115  // compare the 1st and last vertices as well and if their distance is the
116  // largest, we return the index of the last vertex.
117  int findMaxDistanceU(float &maxdist2,
118  int start, int stop) const;
119 
120  int findMaxDistanceV(float &maxdist2,
121  int start, int stop) const;
122 
123  // Evaluate the position or the derivative at unit domain point
124  // (u,v), where u and v MUST be in [0,1]. Return 0 if OK and -1 otherwise.
125  // The normal is not normalized.
126  bool evaluatePointRefMap(
128  GA_AttributeRefMap &map,
129  fpreal u, fpreal v,
130  unsigned du=0, unsigned dv=0) const override;
131  int evaluatePointV4(
132  UT_Vector4 &pos,
133  float u, float v = 0,
134  unsigned du=0, unsigned dv=0) const override;
135 
136  // Refine for all spans with specified number of divisions per span.
138  int numdivs=1) override;
139  void spanRefineUInt(int numdivs=1) override;
141  int numdivs=1) override;
142  void spanRefineVInt(int numdivs=1) override;
143 
144 private:
145  friend std::ostream &operator<<(std::ostream &os, const GEO_PrimMesh &d)
146  {
147  d.saveH9(os, 0,
150  return os;
151  }
152 };
153 #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
static GA_PrimitiveFamilyMask buildFamilyMask()
Definition: GEO_Hull.h:683
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
const GLdouble * v
Definition: glew.h:1391
4D Vector class.
Definition: UT_Vector4.h:166
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:676
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:639
vint4 blend(const vint4 &a, const vint4 &b, const vbool4 &mask)
Definition: simd.h:4648
GLclampf f
Definition: glew.h:3499
virtual bool validate() const =0
const GLuint GLenum const void * binary
Definition: glew.h:3502
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 bias
Definition: glew.h:10274
GLuint start
Definition: glew.h:1253
~GEO_PrimMesh() override
Definition: GEO_PrimMesh.h:34
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &defn)
Definition: GEO_PrimMesh.h:100
static GA_PrimitiveFamilyMask buildFamilyMask()
Definition: GEO_PrimMesh.h:94
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
fpreal64 fpreal
Definition: SYS_Types.h:277
friend std::ostream & operator<<(std::ostream &os, const GEO_PrimMesh &d)
Definition: GEO_PrimMesh.h:145
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
GLuint64EXT * result
Definition: glew.h:14007
Container class for all geometry.
Definition: GA_Detail.h:95
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 int unrollV(int append_pts=1)
GLintptr offset
Definition: glew.h:1682