HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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_LoopType.h"
17 #include "GU_PathFinder.h"
18 #include "GU_PathHedge.h"
19 #include <GA/GA_EdgeGroup.h>
20 #include <GA/GA_ElementGroup.h>
21 #include <GA/GA_Types.h>
22 #include <UT/UT_Array.h>
23 #include <UT/UT_UniquePtr.h>
24 #include <SYS/SYS_Types.h>
25 
26 class GU_Detail;
28 class GEO_Hedge;
29 class GEO_SHedge;
30 class GA_Attribute;
31 class GA_Group;
32 
33 
35 {
36 public:
37  GU_LoopHelper();
38  ~GU_LoopHelper();
39 
40  // New edge loop methods to later fully replace the old ones
41  bool primLoop(GA_Index start, GA_Index end,
42  GU_LoopType loop_type,
43  UT_Array<GEO_SHedge> &loop);
44 
45  bool edgeLoop(GEO_Hedge start, GEO_Hedge end,
46  GU_LoopType loop_type,
47  bool allow_ring_instead,
48  UT_Array<GEO_SHedge> &loop);
49 
50  bool edgeRing(GEO_Hedge start, GEO_Hedge end,
51  GU_LoopType loop_type,
52  UT_Array<GEO_SHedge> &loop);
53 
54  bool pointLoop(GA_Index start, GA_Index end,
55  GU_LoopType loop_type,
56  UT_Array<GEO_SHedge> &loop);
57 
58  bool vertexLoop(GA_Index start, int svtx, GA_Index end,
59  int evtx, GU_LoopType loop_type,
60  UT_Array<GEO_SHedge> &loop);
61 
62  // New edge loop methods to later fully replace the old ones
63  bool primLoop(GA_Index start, GA_Index end,
64  GU_LoopType loop_type,
66 
67  bool edgeLoop(GU_PathHedge start, GU_PathHedge end,
68  GU_LoopType loop_type,
69  bool allow_ring_instead,
70  bool force_find_path,
71  bool & result_is_ring, //out param. True is edge ring, false if edge loop
73 
75  GU_LoopType loop_type,
76  bool allow_ring_instead,
78  {
79  bool tmp;
80  return edgeLoop(start, end, loop_type,
81  allow_ring_instead, false, tmp, loop);
82  }
83 
84  bool edgeRing(GU_PathHedge start, GU_PathHedge end,
85  GU_LoopType loop_type,
87 
88  bool pointLoop(GA_Index start, GA_Index end,
89  GU_LoopType loop_type,
91 
92  bool vertexLoop(GA_Index start, int svtx, GA_Index end,
93  int evtx, GU_LoopType loop_type,
95 
96  //Call to extend an existing path directly
97  bool extendLoop(UT_Array<GU_PathSHedge> & loop);
98  bool extendRing(UT_Array<GU_PathSHedge> & loop,
99  bool is_for_prim_loop = false);
100 
101  // Sets the active detail, should only be called by setActiveNode.
102  void setActiveDetail(const GU_Detail *gdp,
103  const GA_Attribute *uv_attrib = nullptr);
104 
105  // Returns our active detail. May be NULL.
106  const GU_Detail *getActiveDetail() const;
107 
108  // Access our cached ring zero. The first time this is called with a new
109  // detail it will create a new ring zero.
111  *getActiveRingZero();
112 
113  // Access our cached hedge interface. The first time this is called with
114  // a new detail it will create a new hedge interface.
116  *getActiveHedgeInterface();
117 
119  getActivePathHedgeInterface();
120 
121  const GA_Attribute *getActiveUVAttrib();
122 
123  //Used for setting elements to avoid
124  //if replace_existing is true, then any avoid group with the same type
125  //will be replaced. If false, then it will be added to it.
126  void setPreviousPath(const GA_Group * prev_gp,
127  bool replace_existing = true);
128  void resetPreviousPath();
129 
131  bool exclude_collision_group,
132  bool collision_strong_rule)
133  {
134  myCollisionGroup = g;
135  myExcludeCollisionGroup = exclude_collision_group;
136  myCollisionGroupStrong = collision_strong_rule;
137  }
138 private:
139 
140  using LoopFinderUptr = UT_UniquePtr<GU_EdgeLoopFinder>;
141  using RingFinderUptr = UT_UniquePtr<GU_EdgeRingFinder>;
142  using HedgeInterfaceUptr = UT_UniquePtr<const GEO_DetachedHedgeInterface>;
143  using PathHedgeInterfacePtr = UT_UniquePtr<GU_PathHedge::Interface>;
144  using OffsetArrayUptr = UT_UniquePtr<const UT_Array<GA_OffsetArray> >;
145  using SHedgeArray = UT_Array<GU_PathSHedge>;
146 
147  GU_EdgeRingFinder *getLeftRingFinder();
148  GU_EdgeRingFinder *getRightRingFinder();
149 
150  GU_EdgeLoopFinder *getLeftLoopFinder();
151  GU_EdgeLoopFinder *getRightLoopFinder();
152 
153  void addPathToPointGroup(const SHedgeArray &path,
154  GA_PointGroup *grp);
155 
156  void addPathToVertexGroup(const SHedgeArray &path,
157  GA_VertexGroup *grp);
158 
159  void addPathToPrimitiveGroup(const SHedgeArray &path,
160  GA_PrimitiveGroup *grp);
161 
162  // Returns true (and returns the shortest partial edge ring in "path") if
163  // the the start and end edges given by ssh and esh suggest an edge ring
164  // selection more than they do an edge loop one. This is the case exactly
165  // when ssh and esh are distinct and there is a perfect partial edge
166  // from start and end but while no perfect edge loops can be found between
167  // them. If false is returned the shortest perfect edge loop between start
168  // and end is returned as evidence.
169  bool shouldFindEdgeRingInstead(GU_PathSHedge ssh,
171 
172  bool findPartialEdgeLoop(UT_Array<GU_PathSHedge> &loop);
173  bool findPartialEdgeRing(UT_Array<GU_PathSHedge> &loop);
174 
175  bool findEdgeLoop(UT_Array<GU_PathSHedge> &loop,
176  GU_LoopType loop_type,
177  bool same_start_and_end = false);
178 
179  bool findEdgeRing(UT_Array<GU_PathSHedge> &loop,
180  GU_LoopType loop_type,
181  bool is_for_prim_loop = false);
182 
183  exint myActiveDetailId;
184  exint myActiveDetailMetaCount;
185  exint myUVAttribDataId;
186 
187 
188  LoopFinderUptr myLeftLoopFinder;
189  LoopFinderUptr myRightLoopFinder;
190  RingFinderUptr myLeftRingFinder;
191  RingFinderUptr myRightRingFinder;
192 
193  const GU_Detail *myActiveDetail;
194  const GA_Attribute *myUVAttrib;
195 
196  PathHedgeInterfacePtr myPathHedgeInterface;
197 
198  HedgeInterfaceUptr myActiveHedgeInterface;
199  OffsetArrayUptr myActiveRingZero;
200 
201  GA_PointGroupUPtr myPrevPathPts;
202  GA_VertexGroupUPtr myPrevPathVtx;
203  GA_PrimitiveGroupUPtr myPrevPathPrims;
204  GA_EdgeGroupUPtr myPrevPathEdges;
205 
206 
207  const GA_Group * myCollisionGroup = nullptr;
208  //when true, will prevent paths within collision group,
209  //if false will constrain paths to collision group
210  bool myExcludeCollisionGroup = true;
211 
212  //when true will NOT allow paths along boundaries of collision group
213  //when false will allow paths to partially contain elements of collision group
214  bool myCollisionGroupStrong = false;
215 };
216 
217 #endif
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
UT_UniquePtr< GA_VertexGroup > GA_VertexGroupUPtr
GLuint start
Definition: glcorearb.h:475
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
GLboolean GLboolean g
Definition: glcorearb.h:1222
int64 exint
Definition: SYS_Types.h:125
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
GEO_Hedge encapsulates a half-edge (hedge) which is the restriction of.
Definition: GEO_Hedge.h:47
GLuint GLuint end
Definition: glcorearb.h:475
UT_UniquePtr< GA_PrimitiveGroup > GA_PrimitiveGroupUPtr
#define GU_API
Definition: GU_API.h:14
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:640
void setCollisionGroup(const GA_Group *g, bool exclude_collision_group, bool collision_strong_rule)
UT_UniquePtr< GA_PointGroup > GA_PointGroupUPtr
GU_LoopType
Definition: GU_LoopType.h:15
bool edgeLoop(GU_PathHedge start, GU_PathHedge end, GU_LoopType loop_type, bool allow_ring_instead, UT_Array< GU_PathSHedge > &loop)
Definition: GU_LoopHelper.h:74
UT_UniquePtr< GA_EdgeGroup > GA_EdgeGroupUPtr
Definition: GA_EdgeGroup.h:466