HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_PrimPoly.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_PrimPoly.h (C++)
7  *
8  * COMMENTS:
9  * Header file for GU_PrimPoly.h class...
10  *
11  */
12 
13 #pragma once
14 
15 #ifndef __GU_PrimPoly_h__
16 #define __GU_PrimPoly_h__
17 
18 #include "GU_API.h"
19 #include <GEO/GEO_PrimPoly.h>
20 #include <UT/UT_Vector3.h>
21 
23 class GA_Detail;
24 class GEO_ConvertParms;
25 class GEO_Hull;
26 class GEO_PrimCircle;
27 class GEO_PrimRBezCurve;
28 class GEO_PrimNURBCurve;
29 class GEO_PrimTriBezier;
30 class GU_RayInfoHit;
31 class UT_MemoryCounter;
32 
33 /////////////////////////////////////////////////////////////
34 // //
35 // Class: GU_PrimPoly //
36 // Descr: This class is responsible for operations //
37 // done on polygon primitives. As we need to access //
38 // the GA_Detail, the pointer is passed in the //
39 // constructor. The second constructor creates a //
40 // polygon with a given number of points (npts) and //
41 // a flag indicating if it is open or not. //
42 // //
43 /////////////////////////////////////////////////////////////
44 
46 {
47 public:
48  /// NOTE: This constructor should only be called via GU_PrimitiveFactory.
51  : GEO_PrimPoly(gdp, offset)
52  {}
53 
54  /// This constructor is for making a representation of a polygon
55  /// on the stack, so that you can call GU_PrimPoly functions on
56  /// the polygon without needing the detail to allocate one.
59  : GEO_PrimPoly(gdp, offset)
60  { myVertexList = vertex_list; }
61 
62  // Conversion Methods
63 
64  virtual GEO_Primitive *convert(GEO_ConvertParms &parms,
65  GA_PointGroup *usedpts = 0);
66 
67  virtual GEO_Primitive *convertNew(GEO_ConvertParms &parms);
68 
69  GEO_Hull *convertToSurfNew(GEO_ConvertParms &parms);
70  GEO_Hull *convertToPotatoChip(void);
71  GEO_Hull *convertToTrim(GEO_ConvertParms &parms);
72 
73  GEO_PrimRBezCurve *convertToBezierNew(GA_ElementWranglerCache &wranglers,
74  int order, int interphull = 1);
75  GEO_PrimNURBCurve *convertToNURBNew(GA_ElementWranglerCache &wranglers,
76  int order, int interphull = 1);
77  GEO_PrimCircle *convertToCircleNew();
78 
79  // Converts tris into triangle beziers by the PN method.
80  GEO_PrimTriBezier *convertToTriBezier(GA_ElementWranglerCache &wranglers);
81 
82 
83  // Cut a wedge of the primitive given a domain range
84  // ind1 and ind2 are indices to the refined values
85  // They are updated if negative on input, else used as is.
86  // If keep is zero the curve is only refined and the indices
87  // updated.
88  GU_PrimPoly *cut(float u1, float u2,
89  int &ind1, int &ind2, int keep);
90 
91  // Open the primitive at the given domain value
92  void openAt(float u);
93 
94  // This is more powerful than convertNew. It always returns a NEW
95  // object, so free it when you're done with it. It may return a polygon,
96  // a NURB curve or a Bezier curve depending on the type.
97  GEO_Face *reconfigure(unsigned type, int order, bool open,
98  bool nonrational) const;
99 
100  virtual int intersectRay(const UT_Vector3 &o, const UT_Vector3 &d,
101  float tmax = 1E17F, float tol = 1E-12F,
102  float *distance = 0, UT_Vector3 *pos = 0,
103  UT_Vector3 *nml = 0, int accurate = 0,
104  float *u = 0, float *v = 0,
105  int ignoretrim=1) const;
106 
107  // Returns number of hits appended, or minus one if error.
108  // t values in hitList are paramter on poly of hits, assuming
109  // uniform parameterization.
110  virtual int intersect(const GEO_Primitive &prim,
111  UT_Array<GU_RayInfoHit> &hitList,
112  float tol = 0.01F, int ignoretrim=1) const;
113 
114  virtual void clip(UT_Vector3 normal, float distance=0,
115  GA_PrimitiveGroup *clipgrp = NULL);
116 
117  void crease(UT_Vector3 &normal, float d=0, int normalize=1,
118  int outputGroups=0,
119  GA_PrimitiveGroup*above=0,
120  GA_PrimitiveGroup*below=0);
121 
122  /// Optional Build Method
123  /// You may call it in the following manner,
124  /// ptr = GU_PrimPoly::build(bla, bla, bla);
125  static GU_PrimPoly *build(GA_Detail *gdp, int npts,
126  int open=0,
127  int appendpts=1)
128  { return (GU_PrimPoly *)GEO_PrimPoly::build(gdp, npts, open, appendpts); }
129 
130  /// Given a bit array representing the edges in the poly (1 meaning
131  /// delete and 0 meaning keep) delete as many edges as possible.
132  /// If a particular edge cannot be deleted then negate the value
133  /// in removededges[edgenum]. DO NOT CHANGE THE MAGNITUDE!
134  /// Returns 0 if successful, -1 if the poly becomes degenerate, and
135  /// -2 if the poly should be removed. The signature for this method
136  /// is consistent with those in other classes, but note that there is
137  /// never a case where an edge cannot be removed from a polygon.
138  int removeEdges(const UT_BitArray &edgemap,
139  UT_IntArray &, bool del_bridges = true)
140  {
141  GEO_Face *dummy;
142  return removeEdges(edgemap, dummy, del_bridges);
143  }
144 
145  /// Same as above method, but instead of accepting an (unused) array
146  /// of edge indices, it returns one (possibly one of many) polygons
147  /// created because this polygon had to be split.
148  int removeEdges(const UT_BitArray &edgemap,
149  GEO_Face *&newpoly,
150  bool del_bridges=true);
151 
152  /// Same as above, but it returns all polygons created because of polysplit
153  int removeEdges(const UT_BitArray &edgemap,
154  UT_Array<GEO_Face*> &newpoly,
155  bool del_bridges=true);
156 
157 
158  // Looks at the first shared edge between us and poly and checks their
159  // orientation. Returns 0 if they are pointing in opposite directions and
160  // 1 if they are pointing in the same direction and -1 if no shared edge
161  // could be found.
162  int isWindingReversed(const GEO_PrimPoly &poly);
163 
164 private:
165  // Vertex sides is 1 or 0 for each vertex depending on whether
166  // it is above the plane.
167  void makeClippedPoly(const UT_Vector3 &n, float d,
168  int *vtxsides,
169  int bothSides=0,
170  int outputGroups = 0,
171  GA_PrimitiveGroup *above = 0,
172  GA_PrimitiveGroup *below = 0,
173  GA_PrimitiveGroup *delgrp = 0);
174 
175  void computeVertices(GEO_Face &face) const;
176 
177 // Don't warn about overriding deprecated virtual methods
179 };
181 
182 #endif
virtual void clip(UT_Vector3 normal, float distance=0, GA_PrimitiveGroup *clipgrp=NULL)
Definition: GEO_PrimPoly.h:315
#define SYS_DEPRECATED_PUSH_DISABLE()
const GLdouble * v
Definition: glcorearb.h:836
#define SYS_DEPRECATED_POP_DISABLE()
3D Vector class.
#define GA_INVALID_OFFSET
Definition: GA_Types.h:654
GA_Size GA_Offset
Definition: GA_Types.h:617
GLdouble n
Definition: glcorearb.h:2007
virtual int intersect(const GEO_Primitive &prim, UT_Array< GU_RayInfoHit > &hitList, float tol=0.01F, int ignoretrim=1) const
Definition: GEO_PrimPoly.h:307
int removeEdges(const UT_BitArray &edgemap, UT_IntArray &, bool del_bridges=true)
Definition: GU_PrimPoly.h:138
T distance(const UT_Vector4T< T > &v1, const UT_Vector4T< T > &v2)
Definition: UT_Vector4.h:698
static GU_PrimPoly * build(GA_Detail *gdp, int npts, int open=0, int appendpts=1)
Definition: GU_PrimPoly.h:125
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
GLintptr offset
Definition: glcorearb.h:664
#define GU_API
Definition: GU_API.h:12
GridType::Ptr normalize(const GridType &grid, bool threaded, InterruptT *interrupt)
Normalize the vectors of the given vector-valued grid.
virtual int open(float queuesize)
SYS_FORCE_INLINE GU_PrimPoly(GA_Detail *gdp, GA_Offset offset=GA_INVALID_OFFSET)
NOTE: This constructor should only be called via GU_PrimitiveFactory.
Definition: GU_PrimPoly.h:50
SYS_FORCE_INLINE GU_PrimPoly(GA_Detail *gdp, GA_Offset offset, const GA_OffsetListRef &vertex_list)
Definition: GU_PrimPoly.h:58
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
Container class for all geometry.
Definition: GA_Detail.h:95
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
Definition: GEO_PrimPoly.h:296
virtual GEO_Primitive * convertNew(GEO_ConvertParms &parms)
Definition: GEO_PrimPoly.h:290
virtual GEO_Primitive * convert(GEO_ConvertParms &parms, GA_PointGroup *usedpts=0)
Definition: GEO_PrimPoly.h:283
static GEO_PrimPoly * build(GA_Detail *gdp, GA_Size nvertices, bool open=false, bool appendpts=true)
int keep
Definition: png.h:2568