HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_EdgeSplit.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: SOP Library (C++)
7  *
8  * COMMENTS: Splits edges.
9  *
10  */
11 
12 #ifndef __GU_EdgeSplit_h__
13 #define __GU_EdgeSplit_h__
14 
15 #include "GU_API.h"
16 #include <GEO/GEO_PrimPoly.h>
17 #include <UT/UT_IntArray.h>
18 #include <UT/UT_Array.h>
19 #include <UT/UT_VectorTypes.h>
20 
21 class GA_EdgeGroup;
22 class GA_PointGroup;
23 class GA_PrimitiveGroup;
25 class GA_AttributeRefMap;
26 class GEO_Closure;
27 class GU_Detail;
28 class GU_SplitHistory;
29 class GU_SplitHistoryNode;
30 template<typename Prec>
31 class GU_SplitLocT;
33 template<typename Prec>
36 template<typename Prec>
39 template<typename Prec>
42 class gu_PrimToUpdate;
43 class gu_CrossEdge;
44 
46 
47 #include "GU_SplitLoc.h"
48 
49 // The UpdatePrimList is the list kept of all the prims that must be
50 // updated once the split is over. These prims are not involved in any
51 // split, but have been affected by a split (probably because they share
52 // an edge that was split.)
54 {
55 public:
57 
59 
60  void updatePrims(GU_SplitHistory &hist, GU_Detail &gdp,
61  float tolerance,
62  GA_ElementWranglerCache &wranglers,
63  bool createDuplicate = false);
64 
65  GEO_PrimPoly * createDuplicatePoly(GEO_PrimPoly &poly,
66  GU_SplitHistory &hist,
67  GU_Detail &gdp,
68  GA_ElementWranglerCache &wranglers);
69 
70  // Adds to list primlist the polygons that will be getting point pt
71  void getPrimsUsingPoint(GA_Offset pt, UT_IntArray &primlist);
72 };
73 
74 class gu_PrimDistance;
75 
76 
77 // EdgeSplit workhorse.
79 {
80 public:
82  GU_EdgeSplit(GU_Detail &gdp, GA_EdgeGroup *outedges = 0,
83  bool modifyGdp = true, UT_Fpreal32Array *outPositions = NULL);
84  ~GU_EdgeSplit();
85 
86  void doSplit(const GU_SplitLocArray &splitlocs, bool force,
87  bool quadcut, float tolerance, bool quadcomplete,
88  bool fixends, bool grpExcludeExtraEdges);
89 
90 private:
91 
92  // This method takes both inputs, converts them to an edge split location,
93  // if necessary, and calls splitEdge
94  // The parameters:
95  // from - from location
96  // to - to location
97  // path - current path so far
98  // quadcut - true if we are quadcuttin', false otherwise
99  // findingtail - true if we are looking for our tail
100  // pointpass - serial number of passing the responsibility to
101  // other primitives and avoid infinite recursion.
102  void split(const GU_SplitLoc &from, const GU_SplitLoc &to,
103  GU_SplitPath *&path, bool quadcut, bool findingtail,
104  int pointpass);
105  bool simplify(GU_SplitLoc &from, GU_SplitLoc &to);
106 
107  void splitPoly(GEO_PrimPoly &poly, int fromedge, int toedge,
108  float fromt, float tot,
109  GA_Offset newpt0, GA_Offset newpt1);
110 
111  void addEdgeToPoly(GEO_PrimPoly &poly, int fromedge, float fromt,
112  GA_Offset newpt0, GA_Offset newpt1,
113  GEO_PrimPoly &oldPoly,
114  float u, float v);
115 
116  // Returns true if the node was added to the path
117  bool addPathNode(const GU_SplitLoc &from, const GU_SplitLoc &to,
118  GU_SplitPath &path, bool quadcut);
119 
120  void updateNeighbourPrims(const GU_SplitLoc &splitloc);
121 
122  bool restructureSplit(GU_SplitHistoryNodePtr stn, GU_SplitLoc &loc);
123 
124  void executePath(GU_SplitPath &path, int can_insert = -1);
125  void getTransferCandidates(const GU_SplitLoc &from,
126  GA_PrimitiveGroup &grp);
127  bool transferLoc(GU_SplitLoc &loc, GEO_PrimPoly *poly);
128  bool inPath(GEO_PrimPoly *poly, const GU_SplitPath &path);
129  void pruneGroup(const GU_SplitLoc &fromloc, const GU_SplitLoc &toloc,
130  UT_IntArray &primlist, bool quadcut);
131 
132  void getEdgeCandidates(const GU_SplitLoc &loc,
133  const UT_Vector3 &src, const UT_Vector3 &dest,
135  bool quadcut);
136 
137  void sortEdgeCandidates(const GU_SplitLoc &loc,
138  const UT_Vector3 &dest,
140 
141  void getPrimCandidates(const GEO_PrimPoly *poly, GA_Offset pt0,
142  GA_Offset pt1,const GU_SplitPath &path,
143  UT_IntArray &candidates, bool quadcut);
144 
145  GA_Offset getNewPoint(GA_Offset pt0, GA_Offset pt1, fpreal t);
146  GA_Offset getNewPoint(const GEO_PrimPoly &p, const UT_Vector3 &pos,
147  float u, float v);
148 
149  int buildFromPrimArray(const GU_SplitLoc &fromloc,
150  const GU_SplitLoc &toloc,
151  UT_IntArray &fromlist,
152  UT_Array<gu_PrimDistance *> &primarray,
153  bool quadcut);
154 
155  // Takes the path and fills it with the correctly interpolated biases for
156  // quad cuts. The quadclosed flag indicates whether or not the path is
157  // a closed loop. The findingtail flag indicates whether or not we were
158  // trying to find our tail (single-click quadcut).
159  void quadProcessPath(GU_SplitPath &path, bool quadclosed,
160  bool findingtail);
161 
162  void getParticipatingPolys(const GU_SplitLoc &loc,
163  GEO_Closure &closure, UT_IntArray &prims);
164 
165  void interpolateInteriorPoint(GA_Offset &result,
166  GA_AttributeRefMap &map,
167  const GEO_PrimPoly &poly,
168  fpreal u, fpreal v);
169 
170  // ensures that the first and last split locations in the given array are
171  // not on faces, as the algorithm requires that they are. If they are not,
172  // add the closest vertex to the first/last point appropriately
173  void fixFirstLastPoints(GU_SplitLocArray &splitlocs);
174 
175  // returns a split location that is a vertex closest to the given splitloc
176  // skip is a point that will not be considered. Use this if for example you
177  // just came from a point and don't want to return there
178  GU_SplitLoc *closestPoint(const GU_SplitLoc &splitpt,
180 
181  // attempts to fix any quads on the original geometry which have been split
182  // into polygons that are not quads. It only works when the polygon has been
183  // split into exactly two parts, one of which is a quad or a triangle
184  void completeQuads();
185 
186  // adds the point specified to myOutPositions
187  void addToMyOutPositions(GA_Offset pt0, GA_Offset pt1, float t);
188 
189  // Data Members
190  GA_PrimitiveGroup *myTempPrimGrp;
191 
192  // This group will keep track of the new points we add to the geometry
193  // so that we don't add duplicate points (keeps things consolidated
194  GA_PointGroup *myNewPointsGrp;
195  gu_UpdatePrimList myUpdatePrimList;
196  GEO_PrimPoly *lastPoly;
197  GU_SplitHistory *myHistory;
198  GU_Detail &myGdp;
199  GU_SplitPathManager *mySplitPathMan;
200  GA_EdgeGroup *myOutEdges;
201  GA_ElementWranglerCache *myWranglers;
202  bool myForceCut;
203  float myTolerance;
204  bool myHasInsideCut;
205  bool myInsertedFirstPoint;
206  bool myInsertedLastPoint;
207 
208  // this prevents myGdp from being changed. It is used when we want to find
209  // the split path for rendering purposes, but don't want to actually change
210  // the given GU_Detail
211  bool myModifyGdp;
212  // we typically don't want to modify the gdp when we just want a list of
213  // edges being modified/add for rendering purposes. We can't use myOutEdges
214  // because that requires the points to be added to the gdp, so instead we
215  // just use a UT_Fpreal32Array
216  UT_Fpreal32Array *myOutPositions;
217 
218 };
219 
220 #endif
void skip(T &in, int n)
Definition: ImfXdr.h:613
const GLdouble * v
Definition: glcorearb.h:837
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
**But if you need a result
Definition: thread.h:622
#define GA_INVALID_OFFSET
Definition: GA_Types.h:694
GA_Size GA_Offset
Definition: GA_Types.h:653
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
A handle to simplify manipulation of multiple attributes.
#define GU_API
Definition: GU_API.h:14
GLdouble t
Definition: glad.h:2397
SIM_API const UT_StringHolder force
fpreal64 fpreal
Definition: SYS_Types.h:283
UT_SharedPtr< GU_SplitHistoryNode > GU_SplitHistoryNodePtr
Definition: GU_EdgeSplit.h:81
OPENVDB_API SharedPtr< MapBase > simplify(SharedPtr< AffineMap > affine)
reduces an AffineMap to a ScaleMap or a ScaleTranslateMap when it can
void OIIO_UTIL_API split(string_view str, std::vector< string_view > &result, string_view sep=string_view(), int maxsplit=-1)
UT_Array< gu_PrimToUpdate * > myList
Definition: GU_EdgeSplit.h:58
GLenum src
Definition: glcorearb.h:1793