HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GU_LoopHelper.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_LoopHelper.h
7  *
8  * COMMENTS:
9  * This is a helper class for creating nice edge/prim/point loops.
10  */
11 
12 #ifndef __GU_LoopHelper_h__
13 #define __GU_LoopHelper_h__
14 
15 #include "GU_API.h"
16 #include "GU_SelectType.h"
17 #include "GU_PathFinder.h"
18 #include "GU_Detail.h"
19 #include <GEO/GEO_HedgeInterface.h>
20 
22 {
23  GU_LOOP_PARTIAL = 0, // Running from start to end element
24  GU_LOOP_EXTENDED, // Partial, maximally extended quad walks at ends
25  GU_LOOP_CLOSED // Closed loop
26 };
27 
29 {
30 public:
31  GU_LoopHelper();
32  ~GU_LoopHelper();
33 
34  // New edge loop methods to later fully replace the old ones
35  bool primLoop(GA_Index start, GA_Index end,
36  GU_LoopType loop_type,
37  UT_Array<GEO_SHedge> &loop);
38 
39  bool edgeLoop(GEO_Hedge start, GEO_Hedge end,
40  GU_LoopType loop_type,
41  bool allow_ring_instead,
42  UT_Array<GEO_SHedge> &loop);
43 
44  bool edgeRing(GEO_Hedge start, GEO_Hedge end,
45  GU_LoopType loop_type,
46  UT_Array<GEO_SHedge> &loop);
47 
48  bool pointLoop(GA_Index start, GA_Index end,
49  GU_LoopType loop_type,
50  UT_Array<GEO_SHedge> &loop);
51 
52  bool vertexLoop(GA_Index start, int svtx, GA_Index end,
53  int evtx, GU_LoopType loop_type,
54  UT_Array<GEO_SHedge> &loop);
55 
56  // Sets the active detail, should only be called by setActiveNode.
57  void setActiveDetail(const GU_Detail *gdp,
58  const GA_Attribute *uv_attrib = nullptr);
59 
60  // Returns our active detail. May be NULL.
61  const GU_Detail *getActiveDetail() const;
62 
63  // Access our cached ring zero. The first time this is called with a new
64  // detail it will create a new ring zero.
66  *getActiveRingZero();
67 
68  // Access our cached hedge interface. The first time this is called with
69  // a new detail it will create a new hedge interface.
71  *getActiveHedgeInterface();
72 
73  const GA_Attribute *getActiveUVAttrib();
74 
75 private:
76 
82 
83  GU_EdgeRingFinder *getLeftRingFinder();
84  GU_EdgeRingFinder *getRightRingFinder();
85 
86  GU_EdgeLoopFinder *getLeftLoopFinder();
87  GU_EdgeLoopFinder *getRightLoopFinder();
88 
89  void addPathToPointGroup(const SHedgeArray &path,
90  GA_PointGroup *grp);
91 
92  void addPathToVertexGroup(const SHedgeArray &path,
93  GA_VertexGroup *grp);
94 
95  void addPathToPrimitiveGroup(const SHedgeArray &path,
96  GA_PrimitiveGroup *grp);
97 
98  // Returns true (and returns the shortest partial edge ring in "path") if
99  // the the start and end edges given by ssh and esh suggest an edge ring
100  // selection more than they do an edge loop one. This is the case exactly
101  // when ssh and esh are distinct and there is a perfect partial edge
102  // from start and end but while no perfect edge loops can be found between
103  // them. If false is returned the shortest perfect edge loop between start
104  // and end is returned as evidence.
105  bool shouldFindEdgeRingInstead(GEO_SHedge ssh,
106  GEO_SHedge esh, UT_Array<GEO_SHedge> &path);
107 
108  bool findPartialEdgeLoop(UT_Array<GEO_SHedge> &loop);
109  bool findPartialEdgeRing(UT_Array<GEO_SHedge> &loop);
110 
111  bool findEdgeLoop(UT_Array<GEO_SHedge> &loop,
112  GU_LoopType loop_type,
113  bool same_start_and_end = false);
114 
115  bool findEdgeRing(UT_Array<GEO_SHedge> &loop,
116  GU_LoopType loop_type,
117  bool is_for_prim_loop = false);
118 
119  exint myActiveDetailId;
120  exint myActiveDetailMetaCount;
121  exint myUVAttribDataId;
122 
123 
124  LoopFinderUptr myLeftLoopFinder;
125  LoopFinderUptr myRightLoopFinder;
126  RingFinderUptr myLeftRingFinder;
127  RingFinderUptr myRightRingFinder;
128 
129  const GU_Detail *myActiveDetail;
130  const GA_Attribute *myUVAttrib;
131 
132  HedgeInterfaceUptr myActiveHedgeInterface;
133  OffsetArrayUptr myActiveRingZero;
134 };
135 
136 #endif
Definition of a geometry attribute.
Definition: GA_Attribute.h:189
GLuint start
Definition: glcorearb.h:474
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
int64 exint
Definition: SYS_Types.h:115
GEO_Hedge encapsulates a half-edge (hedge) which is the restriction of.
Definition: GEO_Hedge.h:47
GLuint GLuint end
Definition: glcorearb.h:474
#define GU_API
Definition: GU_API.h:11
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:611
GU_LoopType
Definition: GU_LoopHelper.h:21