HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GU_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: GU_PrimPasteDAG.h (C++)
7  *
8  * COMMENTS: Pasted surface class.
9  *
10  */
11 
12 #ifndef __GU_PrimPasteDAG_h__
13 #define __GU_PrimPasteDAG_h__
14 
15 #include "GU_API.h"
16 #include <GEO/GEO_PrimPasteDAG.h>
17 
18 class GEO_ConvertMethod;
19 class GEO_ConvertParms;
20 class UT_MemoryCounter;
21 
23 {
24 public:
26  {
27  method = 0;
28  up = 0;
29  trim = 0; trimscale = 1;
30  height = 0;
31  ubeltwidth = vbeltwidth = 0;
32  keepshape = 0;
33  }
34 
35  int method; // 0 = min distance projection
36  // 1 = vector projection
37  // 2 = parametric mapping
38  // 3 = as is
39 
40  int up; // paste up or down
41  int trim; // trim underlying base
42  float trimscale; // scale amount for trim curve
43  float height; // paste at this elevation
44  UT_Vector3 axis; // proj. axis if projecting along vector
45  float rtol; // ray intersection tolerance
46  int keepshape; // don't deform feature when pasting it
47 
48  float umin; // 0 <= umin <= 1
49  float umax; // 0 <= umax <= 1
50  float vmin; // 0 <= vmin <= 1
51  float vmax; // 0 <= vmax <= 1
52 
53  float ubeltwidth;
54  float vbeltwidth;
55  int ubeltdivs;
56  int vbeltdivs;
57 };
58 
60 {
61 protected:
62  /// NOTE: Primitives should not be deleted directly. They are managed
63  /// by the GA_PrimitiveList and the stash.
64  virtual ~GU_PrimPasteDAG() {}
65 
66 public:
67  /// NOTE: This constructor should only be called via GU_PrimitiveFactory.
70  {}
71 
72  /// Report approximate memory usage.
73  virtual int64 getMemoryUsage() const;
74 
75  /// Count memory usage using a UT_MemoryCounter in order to count
76  /// shared memory correctly.
77  /// NOTE: This should always include sizeof(*this).
78  virtual void countMemory(UT_MemoryCounter &counter) const;
79 
80  virtual const GA_PrimitiveDefinition &getTypeDef() const
81  {
82  UT_ASSERT(theDefinition);
83  return *theDefinition;
84  }
85 
86  // NOTE: For static member functions please call in the following
87  // manner. <ptrvalue> = GU_PrimPasteDAG::<functname>
88  // i.e. pdagptr = GU_PrimPasteDAG::build(params...);
89 
90  // Optional Build Method. Returns 0 if it fails.
91  static GU_PrimPasteDAG *build(GU_Detail *gudp, GEO_TPSurf &root,
92  int chkpaste = 0);
93  static GU_PrimPasteDAG *build(GU_Detail *gudp, GEO_PasteSurf &root,
94  int chkpaste = 0);
95 
96  // Conversion methods
97  virtual GEO_Primitive *convert(GEO_ConvertParms &parms,
98  GA_PointGroup *usedpts = 0);
99  virtual GEO_Primitive *convertNew(GEO_ConvertParms &parms);
100 
101  virtual void normal(NormalComp &output) const;
102 
103  // Intersect us with a ray and return 1 if we have a hit, else 0:
104  virtual int intersectRay(const UT_Vector3 &o, const UT_Vector3 &d,
105  float tmax = 1E17F, float tol = 1E-12F,
106  float *distance = 0, UT_Vector3 *pos = 0,
107  UT_Vector3 *nml = 0, int accurate = 0,
108  float *u = 0, float *v = 0,
109  int ignoretrim = 1) const;
110 
111  // Find minimum distance to a point and return 1 if found. 0 otherwise:
112  int minimum(const UT_Vector3 &p, float distmax = 1E17F,
113  float *distance = 0, float *u = 0,
114  float *v = 0, int accurate = 1) const;
115 
116  // Find minimum distance between two primitives and return 1 if found,
117  // 0 otherwise. (u1,v1) is on us, (u2,v2) is on prim.
118  int minimum(const GEO_Primitive &prim, float distmax = 1E17F,
119  float *distance = 0, float *u1 = 0,
120  float *v1 = 0, float *u2 = 0, float *v2 = 0,
121  int accurate = 1) const;
122 
123  // Various pasting methods:
125  GEO_PasteSurf *overlay(GEO_PasteSurf &child, GU_PrimPasteDAG &dag,
126  const GU_PasteParms &parms, int at = 1);
127  GEO_PasteSurf *replace(GEO_PasteSurf &child, GU_PrimPasteDAG &dag,
128  int at = 1, int up = 1, float height = 0.0f);
129  GEO_PasteSurf *spawn (GEO_PasteSurf &child, const GU_PasteParms &);
130 
131 
132 protected:
133  // Virtual (shallow) c-tor that can be used by classes derived
134  // from us to instantiate themselves at this level:
135  virtual GEO_PasteSurfDAG *newDAGSpecies(void) const;
136 
137 private:
138  // Return 0 if OK, else -1.
139  int evaluateSurface(GEO_ConvertMethod &method,
140  int featurecoord,
141  UT_Vector4Array &pos,
142  int &nu, int &nv) const;
143  // Return 0 if OK, else -1.
144  int getUVInterval (const GEO_PasteSurf &surf,
145  float &umin, float &vmin,
146  float &umax, float &vmax) const;
147 
148  // Return 0 if OK, else -1.
149  int getProjectionUV(const UT_Vector3 &axis, float tol,
150  int vecproj, GU_PrimPasteDAG &dag,
151  GP_Point &b1, GP_Point &b2,
152  GP_Point &b3, GP_Point &b4);
153 
154  // b1..b4 are in the local frame the surface, but we need
155  // them in world space:
156  void toWorld(const GEO_PasteSurf &surf,
157  GP_Point &b1, GP_Point &b2,
158  GP_Point &b3, GP_Point &b4) const;
159 
160  static GA_PrimitiveDefinition *theDefinition;
161  friend class GU_PrimitiveFactory;
163 };
165 
166 #endif
GP_Domain * spawn(GP_Domain &child, const UT_BoundingRect &brect, float ubwidth=0, float vbwidth=0, int ubdivs=2, int vbdivs=2)
#define SYS_DEPRECATED_PUSH_DISABLE()
const GLdouble * v
Definition: glcorearb.h:836
#define SYS_DEPRECATED_POP_DISABLE()
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:817
UT_Vector3 axis
virtual int64 getMemoryUsage() const
Definition: GA_Primitive.h:204
#define GA_INVALID_OFFSET
Definition: GA_Types.h:654
virtual void normal(NormalComp &output) const =0
GA_Size GA_Offset
Definition: GA_Types.h:617
long long int64
Definition: SYS_Types.h:106
GLfloat f
Definition: glcorearb.h:1925
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:102
T distance(const UT_Vector4T< T > &v1, const UT_Vector4T< T > &v2)
Definition: UT_Vector4.h:634
virtual void countMemory(UT_MemoryCounter &counter) const
int method
Definition: png.h:1924
GLintptr offset
Definition: glcorearb.h:664
#define GU_API
Definition: GU_API.h:11
GLint GLsizei GLsizei height
Definition: glcorearb.h:102
virtual ~GU_PrimPasteDAG()
virtual int intersectRay(const UT_Vector3 &o, const UT_Vector3 &d, float tmax=1E17F, float tol=1E-12F, float *distance=0, UT_Vector3 *pos=0, UT_Vector3 *nml=0, int accurate=0, float *u=0, float *v=0, int ignoretrim=1) const
GA_API const UT_StringHolder up
GLfloat GLfloat v1
Definition: glcorearb.h:816
GU_PrimPasteDAG(GA_Detail *d, GA_Offset offset=GA_INVALID_OFFSET)
NOTE: This constructor should only be called via GU_PrimitiveFactory.
Container class for all geometry.
Definition: GA_Detail.h:96
virtual GEO_Primitive * convert(GEO_ConvertParms &parms, GA_PointGroup *usedpts=0)=0
Definition of a geometric primitive.
GP_Domain * paste(GP_DomainDAG &child, int keepshape=0)
virtual GEO_PasteSurfDAG * newDAGSpecies(void) const
virtual const GA_PrimitiveDefinition & getTypeDef() const
virtual GEO_Primitive * convertNew(GEO_ConvertParms &parms)=0