HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_UVFlatten.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 Library (C++)
7  *
8  */
9 
10 #ifndef __GU_UVFlatten_h__
11 #define __GU_UVFlatten_h__
12 
13 #include "GU_API.h"
14 #include "GU_Detail.h"
15 #include "GU_UVUtils.h"
16 #include "GU_TriangleMesh.h"
17 
18 #include <GEO/GEO_HedgeInterface.h>
19 
20 #include <GA/GA_Edge.h>
21 #include <GA/GA_EdgeGroup.h>
22 
23 #include <UT/UT_Map.h>
24 #include <UT/UT_ParallelUtil.h>
25 #include <UT/UT_UniquePtr.h>
26 #include <UT/UT_TriangleMesh.h>
27 #include <UT/UT_Set.h>
28 
29 // #define REPORT_ABF_ANGLES
30 
31 namespace GU_UVFlatten
32 {
33 
34 using namespace GU_UVUtils;
35 
40 
42 
43 enum Status
44 {
45  SUCCESS = 0,
50 };
51 
52 // Various flattening methods
53 enum Method
54 {
55  SCP, // Spectral Conformal Parameterization (SCP)
56  LSCM, // Least Squares Conformal Mapping (LSCM)
57  LINEAR_ABF, // Angle-Based Flattening (Linearized version)
58  PROJECT, // Projection onto best-fitting plane
59 };
60 
61 template <typename T>
62 struct PtrRange
63 {
64  PtrRange(const T *s, const T *e) :
65  myStart(s), myEnd(e) { }
66 
68  const T *begin() const { return myStart; }
69 
71  const T *end() const { return myEnd; }
72 
74  exint size() const { return exint(myEnd - myStart); }
75 
77  const T &first() const
78  { UT_ASSERT_P(size() > 0); return *myStart; }
79 private:
80  const T *myStart, *myEnd;
81 };
82 
84 
85 class ConstraintSet;
86 
87 // Islands encapsulate the needed abstractions for flattening a subset of
88 // polygons in a geometry detail. It takes care of building the triangle mesh
89 // required by flattening algorithms and the mapping between the physical
90 // geometry and the virtual mesh. Once created, polygons can be added to an
91 // island by calling appendPoly(). Once all island polygons are appended,
92 // a call to buildMesh() is needed to setup the internal structures before
93 // calling any of the flattenX() or related methods.
94 
96 {
97 public:
98  explicit Island(const GU_Detail *gdp, int idx = -1,
99  GA_RWHandleI vtx_pt_attr = GA_RWHandleI(),
100  Tessellation tessellation = TRIANGULATE_ALL) :
101  GU_TriangleMeshR(gdp, vtx_pt_attr, tessellation),
102  myIndex(idx) { }
103 
105  int getIndex() const { return myIndex; }
106 
107  Status flatten(Method method,
108  const ConstraintSet &constraints,
109  RWHandleV3R uvh) const;
110 
111  Status flattenLSCM(const ConstraintSet &constraints,
112  RWHandleV3R uvh) const;
113 
114  Status flattenSCP(const ConstraintSet &constraints,
115  RWHandleV3R uvh) const;
116 
117  Status flattenLinearABF(const ConstraintSet &constraints,
118  RWHandleV3R uvh) const;
119 
121 
122  fpreal calcArea(ROHandleV3R uvh,
123  UT_Vector3R *center = nullptr) const;
124 
125  void balance(RWHandleV3R uvh) const;
126 
127  void reposition(const ConstraintSet &constraints,
128  ROHandleV3R &orig_uvh,
129  RWHandleV3R &uvh,
130  fpreal area_scale = 0.0,
131  bool use_custom_pins = false) const;
132 
133  bool verifyFinite(ROHandleV3R &uvh) const;
134 
135 private:
136  int myIndex = -1;
137 };
138 
139 /// An IslandBundle is used to store information about a collection (bundle)
140 /// of *primary* islands determined by partitioning the polygons in a primtiive
141 /// group 'prims' of a detail 'gdp' using the given group 'seams' of edges.
142 /// The bundle also supports a "remapping" of the islands into *secondary*
143 /// islands (or just "islands" after the effect) by recutting them using a
144 /// second set of seams. Originally this was meant to be a simple "refining"
145 /// of islands in which each primary island provided access to the secondary
146 /// ones into which it was divided. Later on support was added to allow the
147 /// repartitioning potentially remap the entire scene by erasing parts of the
148 /// original seams that defined the primary islands thereby merging fragments
149 /// from distinct primary islands into secondary ones. In this setting, each
150 /// secondary island will be registered as a descendent of *one* of
151 /// possibly several primary islands it overlaps. The other overlapped primary
152 /// islands will be aware of having lost part (or all) of their territory
153 /// to secondary islands held by other primary ones but without access to them.
154 ///
155 /// The bundle provides methods to iterate over all primary, or current
156 /// islands. In addition, the bundle provides a mechanism for quickly marking
157 /// islands dirty and resetting all dirty flags. In particular, the building
158 /// of secondary islands is optimized to efficiently determine the affected
159 /// islands and set their dirty flags.
160 
162 {
163 public:
164  IslandBundle(const GU_Detail *gdp,
165  const GA_PrimitiveGroup *prims,
166  const GA_EdgeGroup *seams,
167  Tessellation tessellation,
168  const GEO_DetachedHedgeInterface *hip
169  = nullptr);
170 
171  ~IslandBundle();
172 
173  // Repartition the collection of islands along the islet_seams and assign
174  // the created islets to (one of) parent islands.
175  void repartitionIslands(const GA_EdgeGroup *new_seams);
176 
177  // Clear all island dirty flags.
178  void clearDirtyFlags() { mySerial++; }
179 
180  // The total range of possible island indices. Note that some can be vacant.
181  int numIslandIndices() const
182  { return int(myIslandInfos.size()); }
183 
184  // Number of primary "islands", those cut by the original set of seams.
185  int numPrimaryIslands() const
186  { return myNumPrimaryIslands; }
187 
188  const
189  Island &island(int i) const
190  { return myIslandInfos(i).island(); }
191 
192  Island &island(int i) { return myIslandInfos(i).island(); }
193 
195  int polyPrimaryIsland(GA_Offset poly) const
196  { return myPolyPrimaryIsland.get(poly); }
197 
199  int polyIsland(GA_Offset poly) const
200  {
201  int j = polyPrimaryIsland(poly);
202  if (j < 0)
203  return -1;
204 
205  if (getNext(j) >= 0)
206  return myPolySecondaryIsland.get(poly);
207 
208  return j;
209  }
210 
211  bool isPrimary(const Island &island) const
212  { return island.getIndex() < myNumPrimaryIslands; }
213 
216  { return vertexPrimaryIsland(myHip->srcVertex(h)); }
217 
220  { return polyPrimaryIsland(
221  myGdp->vertexPrimitive(vtx)); }
222 
224  int vertexIsland(GA_Offset vtx) const
225  { return polyIsland(myGdp->vertexPrimitive(vtx)); }
226 
227  bool hasPointIndex() const
228  { return myIslandVtxPt.isValid(); }
229 
231  int vtxIslandPt(GA_Offset vtx, int island_idx) const
232  { return island_idx < myNumPrimaryIslands
233  ? myIslandVtxPt.get(vtx)
234  : myIsletVtxPt.get(vtx); }
235 
236  void getIslandIndices(UT_IntArray &idxs) const;
237 
238  template<typename Func>
239  void forEachIslandIndex(Func func, bool parallel = false)
240  {
241  UT_IntArray idxs(myIslandInfos.size());
242  getIslandIndices(idxs);
243  if (parallel)
244  UTparallelForEachNumber(idxs.size(),
245  [&](const UT_BlockedRange<exint> &r)
246  {
247  for (exint j = r.begin(), je = r.end(); j != je; ++j)
248  func(idxs(j));
249  });
250  else
251  for (int i : idxs)
252  func(i);
253  }
254 
255  template<typename Func>
256  void forEachIsland(Func func)
257  {
258  forEachIslandIndex([&](int i) { func(island(i)); }, false);
259  }
260 
261  template<typename Func>
263  {
264  forEachIslandIndex([&](int i) { func(island(i)); }, true);
265  }
266 
267  template<typename Func>
269  bool parallel = false) const
270  {
271  UT_IntArray idxs(myIslandInfos.size());
272  getIslandIndices(idxs);
273  if (parallel)
274  UTparallelForEachNumber(idxs.size(),
275  [&](const UT_BlockedRange<exint> &r)
276  {
277  for (exint j = r.begin(), je = r.end(); j != je; ++j)
278  func(idxs(j));
279  });
280 
281  else
282  for (int i : idxs)
283  func(i);
284  }
285 
286  template<typename Func>
287  void forEachIsland(Func func) const
288  {
289  forEachIslandIndex([&](int i) { func(island(i)); }, false);
290  }
291 
292  template<typename Func>
293  void parallelForEachIsland(Func func) const
294  {
295  forEachIslandIndex([&](int i) { func(island(i)); }, true);
296  }
297 
298  template<typename Func>
299  void forEachDirtyIsland(Func func) const
300  {
301  forEachIslandIndex([&](int i)
302  {
303  if (isDirty(i))
304  func(island(i));
305  }, false);
306  }
307 
308  template<typename Func>
310  {
311  forEachIslandIndex([&](int i)
312  {
313  if (isDirty(i))
314  func(island(i));
315  }, true);
316  }
317 
318  template<typename Func>
320  {
321  forEachIslandIndex([&](int i)
322  {
323  if (isDirty(i))
324  func(island(i));
325  }, false);
326  }
327 
328  template<typename Func>
330  {
331  forEachIslandIndex([&](int i)
332  {
333  if (isDirty(i))
334  func(island(i));
335  }, true);
336  }
337 
338 
339  template<typename Func>
340  void forEachPrimaryIsland(Func func) const
341  {
342  for (int i = 0; i < myNumPrimaryIslands; i++)
343  func(island(i));
344  }
345 
346  bool isDirty(const Island &island) const
347  { return isDirty(island.getIndex()); }
348 
349  void makeDirty(const Island &island)
350  { makeDirty(island.getIndex()); }
351 
352 private:
353  using EdgeSet = UT_Set<GA_Edge>;
354  using EdgeArray = UT_Array<GA_Edge>;
355 
356  GA_RWHandleI &getVertexPointAttrib(bool primary);
357 
358  int getNext(int i) const
359  { return myIslandInfos(i).getNext(); }
360 
361  void setNext(int i, int j)
362  { return myIslandInfos(i).setNext(j); }
363 
364  bool isVacant(int i) const
365  { return myIslandInfos(i).isVacant(); }
366 
367  int newIsland(bool primary = true);
368  void freeIsland(int i);
369 
370  // Add a new islet to island i.
371  int newSecondaryIsland(int i);
372 
373  // Destroy all secondary islands registered to primary island i.
374  void destroyDependentSecondaryIslands(int i);
375 
376  void breakPrimaryIslands(const UT_IntArray &islands,
377  const GA_EdgeGroup *seams,
378  const EdgeSet &changed_seam_edges);
379 
380  void markOvertaken(int i) { setNext(i, -2); }
381  bool isOvertaken(int i) const
382  { return getNext(i) == -2; }
383 
384  // Is a primary island unchanged by secondary cutting?
385  bool isUndivided(int i) const
386  { return getNext(i) == -1; }
387 
388 
389  void makeDirty(int i)
390  {
391  myIslandInfos(i).serial(mySerial);
392  // myIslandInfos(i).dirty(true);
393  }
394 
395  bool isDirty(int i) const
396  {
397  return // myIslandInfos(i).dirty()
398  // &&
399  myIslandInfos(i).serial() == mySerial;
400  }
401 
402  struct LabeledEdge
403  {
404  LabeledEdge(int i, GA_Edge e) :
405  island(i), edge(SYSmin(e.p0(), e.p1()),
406  SYSmax(e.p0(), e.p1()))
407  { }
408 
409  int island;
410  GA_Edge edge;
411  };
412 
413  using LabeledEdgeArray = UT_Array<LabeledEdge>;
414  using IslandUptr = UT_UniquePtr<Island>;
416  using HedgeInterfaceUptr = UT_UniquePtr<HedgeInterface>;
417 
418  void generateLabeledSeams(const GA_EdgeGroup *seams,
419  LabeledEdgeArray &labeled_seams) const;
420 
421 
422  // Dirty flag of the island is only taken seriously if the island's
423  // Serial matches the managers. When manager's serial is bumped, all
424  // dirty flags are assumed to have been dealt with.
425 
426  struct IslandInfo
427  {
428  void resetIsland(Island *island_ptr = nullptr)
429  { myIsland.reset(island_ptr); }
430 
431  bool isVacant() const { return myIsland == nullptr; }
432 
433  const Island &island() const { return *myIsland; }
434  Island &island() { return *myIsland; }
435 
436  int serial() const { return mySerial; }
437  void serial(int i) { mySerial = i; }
438 
439  void dirty(bool b) { myDirty = b; }
440  bool dirty() const { return myDirty; }
441 
442  bool hasIslets() const { return myNext >= 0; }
443 
444  int getNext() const { return myNext; }
445  void setNext(int i) { myNext = i; }
446 
447  private:
448  bool myDirty = false;
449  int mySerial = 0;
450 
451  IslandUptr myIsland;
452  int myNext = -1;
453  };
454 
455 
456  using IslandInfoArray = UT_Array<IslandInfo>;
457 
458  LabeledEdgeArray myLabeledIsletSeamEdges;
459 
460  IslandInfoArray myIslandInfos;
461 
462  GA_RWHandleI myPolyPrimaryIsland;
463  GA_RWHandleI myPolySecondaryIsland;
464 
465  int myNumPrimaryIslands = 0;
466  int myNumIslands = 0;
467 
468  UT_IntArray myFreeIndices;
469  Tessellation myTessellation;
470 
471  const GU_Detail *myGdp;
472 
473  HedgeInterfaceUptr myHiup;
474  HedgeInterface *myHip;
475 
476  GA_RWHandleI myIslandVtxPt, myIsletVtxPt;
477 
478  int mySerial = 0;
479 };
480 
481 // A ConstraintSet carries all possible constraints (applicable to various
482 // methods) for a single island. As it stands now, the constraints can be:
483 //
484 // - Pins: vertex offset plus UV coordinates
485 //
486 // - Axis constraints: list of vertices which should be aligned in u or v
487 // direction.
488 //
489 // - Line constraints: list of vertices that should end up in a line.
490 //
491 // - Flags (constraints applied to entire island)
492 
493 // The constraints are categorized into three types:
494 // Point constraints target a single island point.
495 // Group constraints target a group island vertices (tri-hedges).
496 // Island constraints target the entire island.
497 
498 template <typename T>
500 {
501 public:
502  using Base = UT_Array<T>;
503 
504  void deleteIndices(const UT_IntArray &idxs)
505  {
506  if (idxs.size() == 0)
507  return;
508 
509  auto move_segment = [&](int s, int e, int &j)
510  {
511  for (int i = s; i < e; i++, j++)
512  (*this)(j) = (*this)(i);
513  };
514 
515  int j = idxs(0);
516  for (int i = 1, ie = int(idxs.size()); i < ie; i++)
517  move_segment(idxs(i - 1) + 1, idxs(i), j);
518 
519  move_segment(idxs.last() + 1, int(Base::size()), j);
520  Base::setSize(j);
521  }
522 
523  bool operator!=(const ElementConstraintList<T> &other) const
524  { return !(Base::operator==(other)); }
525 };
526 
527 template <typename T>
529 {
530 public:
531  GroupConstraintList() { myFirst.append(0); }
532 
533  void add(T data = T())
534  { myFirst.append(myFirst.last());
535  myData.append(data); }
536 
537  void appendVertex(int i)
538  { myElements.append(i); myFirst.last()++; }
539 
540  int size() const
541  { return int(myFirst.size()) - 1; }
542 
544 
545  struct GroupHandle
546  {
549  int grp_idx) :
550  myList(set), myIndex(grp_idx) { }
551 
554  { return myList->elements(myIndex); }
555 
557  const T &data() const
558  { return myList->data(myIndex); }
559 
560  private:
561  using List = GroupConstraintList<T>;
562  const List *myList;
563  int myIndex;
564  };
565 
567  GroupHandle operator()(int i) const
568  { return GroupHandle(this, i); }
569 
571  ElementRange elements(int i) const
572  { return { myElements.data() + myFirst(i),
573  myElements.data() + myFirst(i + 1) }; }
574 
575  bool operator==(const GroupConstraintList &other) const
576  { return (myElements == other.myElements
577  && myFirst == other.myFirst
578  && myData == other.myData); }
579 
580  bool operator!=(const GroupConstraintList &other) const
581  { return !operator==(other); }
582 
583 private:
584 
585  int size(int i) const
586  { return myFirst(i + 1) - myFirst(i); }
587 
589  const T &data(int i) const { return myData(i); }
590 
591 
592  UT_IntArray myElements;
593  UT_IntArray myFirst;
594  UT_Array<T> myData;
595 };
596 
598 {
599 public:
600  enum AlignDir { U_AXIS = 0, V_AXIS };
601 
602  bool isEmpty() const;
603  bool isTrivial() const;
604 
605  // Returns true if the flattening result under this constraint set
606  // is going to be interpretable as a repositioning of those in the
607  // "other" set.
608  bool isRepositioningOf(const ConstraintSet &other) const;
609 
610  bool operator==(const ConstraintSet &other) const;
611  bool operator!=(const ConstraintSet &other) const
612  { return !(*this == other); }
613 
614  struct BaseInfo
615  {
616  BaseInfo() = default;
617  BaseInfo(int id) : myId(id) { }
618 
620  bool operator==(const BaseInfo &other) const
621  { return true; }
622 
624  int id() const { return myId; }
625 
626  int myId = -1;
627  };
628 
629  struct PinInfo : public BaseInfo
630  {
631  PinInfo() = default;
632  PinInfo(int pt, UT_Vector3R uv, int id = -1,
633  int ref_pt = -1, UT_Vector3R refuv
634  = { 0, 0, 0 }) :
635  BaseInfo(id), myPoint(pt), myUV(uv),
636  myRefPoint(ref_pt), myRefUV(refuv) { }
637 
639  int point() const { return myPoint; }
640 
642  int refPoint() const { return myRefPoint; }
643 
645  fpreal u() const { return myUV.x(); }
646 
648  fpreal v() const { return myUV.y(); }
649 
651  UT_Vector3R uv() const { return myUV; }
652 
654  UT_Vector3R refuv() const { return myRefUV; }
655 
657  bool operator==(const PinInfo &pin) const
658  {
659  return myUV == pin.myUV && myRefUV == pin.myRefUV
660  && myPoint == pin.myPoint && myRefPoint == pin.myRefPoint;
661  }
662 
663  int myPoint, myRefPoint, myId;
664  UT_Vector3R myUV, myRefUV;
665  };
666 
667  struct AngleInfo
668  {
669  AngleInfo() = default;
670  AngleInfo(int i_in, int i_out, fpreal angle = M_PI) :
671  myHedgeIn(i_in), myHedgeOut(i_out),
672  myAngle(angle) { }
673 
675  int hedgeIn() const { return myHedgeIn; }
676 
678  int hedgeOut() const { return myHedgeOut; }
679 
681  fpreal angle() const { return myAngle; }
682 
684  bool operator==(const AngleInfo &other) const
685  { return myHedgeIn == other.myHedgeIn
686  && myHedgeOut == other.myHedgeOut
687  && myAngle == other.myAngle; }
688 
689  private:
690  int myHedgeIn, myHedgeOut;
691  fpreal myAngle;
692  };
693 
694  struct AlignInfo : public BaseInfo
695  {
696  AlignInfo() = default;
697  explicit AlignInfo(AlignDir dir, int id = -1) :
698  BaseInfo(id), myDir(dir) { }
699 
701  AlignDir dir() const { return myDir; }
702 
704  bool operator==(const AlignInfo &other) const
705  { return myDir == other.myDir; }
706 
707  private:
708  AlignDir myDir;
709  };
710 
716 
717  const PinSet &pins() const { return myPins; }
718  PinSet &pins() { return myPins; }
719 
720  const
721  AngleSet &angles() const { return myAngles; }
722  AngleSet &angles() { return myAngles; }
723 
724  const
725  AlignGroupSet &alignedSets() const { return myAlignGroups; }
726  AlignGroupSet &alignedSets() { return myAlignGroups; }
727 
728  const
729  StraightenGroupSet &straightSets() const { return myStraightGroups; }
730  StraightenGroupSet &straightSets() { return myStraightGroups; }
731 
732 private:
733 
734  PinSet myPins;
735  AngleSet myAngles;
736  AlignGroupSet myAlignGroups;
737  StraightenGroupSet myStraightGroups;
738 };
739 
741 {
742 public:
745 
746  explicit ConstraintBundle(const IslandBundle &islands) :
747  myIslands(islands)
748  { }
749 
750  void addPin(GA_Offset vtx, UT_Vector3R uv, int id = -1,
751  GA_Offset ref_vtx = GA_INVALID_OFFSET,
752  UT_Vector3R refuv = { 0, 0, 0 });
753 
754  // Remove duplicate pins, ie all but the first pin associated to each
755  // island point. Only non-negative pin ids are returned.
756  void sanitizePins(UT_IntArray *removed_pin_ids = nullptr);
757 
758  bool addAlignGroup(const GA_OffsetArray &vtxs,
759  AlignDir dir, int id = -1);
760 
761  bool addStraightenGroup(const GA_OffsetArray &vtxs,
762  int id = -1);
763 
765  { return myIslandConstraints[island.getIndex()]; }
766 
767  const
768  ConstraintSet &islandConstraints(const Island &island) const
769  {
770  auto it = myIslandConstraints.find(island.getIndex());
771  if (it != myIslandConstraints.end())
772  return it->second;
773 
774  return theEmptyConstraintSet;
775  }
776 
777 private:
778  using ConstraintSetMap = UT_Map<int, ConstraintSet>;
779 
780  const
781  IslandBundle &myIslands;
782  ConstraintSetMap myIslandConstraints;
783 
784  // static
785  ConstraintSet theEmptyConstraintSet;
786 };
787 
790 
791 // Flatten the mesh by projecting it onto its best fitting plane.
792 
794  const GetFunctor<UT_Vector3R> &get_pt_pos,
795  const SetFunctor<UT_Vector2R> &set_pt_uv);
796 
797 // Least Squares Conformal Map flattening of mesh. The first two pins in
798 // constraint set are used to flatten the island. If less than two pins are
799 // given, the two flattening pins are picked automatically.
800 
801 GU_API Status flattenLSCM(const TriMesh &mesh,
802  const ConstraintSet &constraints,
803  const GetFunctor<UT_Vector3R> &get_pt_pos,
804  int outer_boundary_comp,
805  const SetFunctor<UT_Vector2R> &set_pt_uv);
806 
807 // Least Squares Conformal Map flattening of mesh using explicitly-specified
808 // points to pin and supplied conformal energy data.
809 
810 GU_API Status flattenLSCM(const TriMesh &mesh,
811  const ConstraintSet &constraints,
812  const GetFunctor<fpreal> &hedge_apx_cotan,
813  const GetFunctor<fpreal> &hedge_tri_area,
814  int pin0_pt, int pin1_pt,
815  const SetFunctor<UT_Vector2R> &set_pt_uv);
816 
817 GU_API Status flattenSCP(const TriMesh &mesh,
818  const ConstraintSet &constraints,
819  const GetFunctor<UT_Vector3R> &get_pt_pos,
820  int outer_boundary_comp,
821  const SetFunctor<UT_Vector2R> &set_pt_uv);
822 
823 GU_API Status flattenSCP(const TriMesh &mesh,
824  const ConstraintSet &constraints,
825  const GetFunctor<fpreal> &hedge_apx_cotan,
826  const GetFunctor<fpreal> &hedge_tri_area,
827  int outer_boundary_comp,
828  const SetFunctor<UT_Vector2R> &set_pt_uv);
829 
831  const ConstraintSet &constraints,
832  const GetFunctor<UT_Vector3R> &get_pt_pos,
833  int outer_boundary_comp,
834  const SetFunctor<fpreal> &set_vtx_angle);
835 
837  const ConstraintSet &constraints,
838  AngleConstraintArray &angle_constraints);
839 
840 GU_API void calcConformalEnergyData(const TriMesh &mesh,
841  const GetFunctor<UT_Vector3R> &get_pt_pos,
842  UT_FprealArray &hedge_apx_cotan,
843  UT_FprealArray &hedge_tri_area);
844 
845 
846 GU_API int longestBoundaryComponent(const TriMesh &mesh,
847  const GetFunctor<UT_Vector3R> &get_pt_pos);
848 
849 GU_API void pickLSCMDefaultPins(const TriMesh &mesh,
850  const GetFunctor<UT_Vector3R> &get_pt_pos,
851  int outer_boundary_comp,
852  int &pin0_pt, int &pin1_pt);
853 
854 } // namespace GU_UVFlatten;
855 
856 
857 #endif
GLdouble s
Definition: glew.h:1390
#define SYSmax(a, b)
Definition: SYS_Math.h:1447
T & last()
Definition: UT_Array.h:599
SYS_FORCE_INLINE GroupHandle(const GroupConstraintList< T > *set, int grp_idx)
Definition: GU_UVFlatten.h:548
void parallelForEachDirtyIsland(Func func) const
Definition: GU_UVFlatten.h:309
Definition: UT_Set.h:58
SYS_FORCE_INLINE int polyPrimaryIsland(GA_Offset poly) const
Definition: GU_UVFlatten.h:195
GLuint id
Definition: glew.h:1679
GLsizeiptr size
Definition: glew.h:1681
void UTparallelForEachNumber(IntType nitems, const Body &body)
std::function< T(int)> GetFunctor
Definition: GU_UVUtils.h:26
int numPrimaryIslands() const
Definition: GU_UVFlatten.h:185
void forEachIslandIndex(Func func, bool parallel=false)
Definition: GU_UVFlatten.h:239
bool isDirty(const Island &island) const
Definition: GU_UVFlatten.h:346
GU_API void pickLSCMDefaultPins(const TriMesh &mesh, const GetFunctor< UT_Vector3R > &get_pt_pos, int outer_boundary_comp, int &pin0_pt, int &pin1_pt)
GA_API const UT_StringHolder uv
SYS_FORCE_INLINE int hedgeOut() const
Definition: GU_UVFlatten.h:678
SYS_FORCE_INLINE int polyIsland(GA_Offset poly) const
Definition: GU_UVFlatten.h:199
SYS_FORCE_INLINE fpreal v() const
Definition: GU_UVFlatten.h:648
void deleteIndices(const UT_IntArray &idxs)
Definition: GU_UVFlatten.h:504
void parallelForEachIsland(Func func) const
Definition: GU_UVFlatten.h:293
void forEachIsland(Func func) const
Definition: GU_UVFlatten.h:287
const Island & island(int i) const
Definition: GU_UVFlatten.h:189
SYS_FORCE_INLINE int vertexIsland(GA_Offset vtx) const
Definition: GU_UVFlatten.h:224
SYS_FORCE_INLINE fpreal u() const
Definition: GU_UVFlatten.h:645
SYS_FORCE_INLINE int getIndex() const
Definition: GU_UVFlatten.h:105
void forEachPrimaryIsland(Func func) const
Definition: GU_UVFlatten.h:340
SYS_FORCE_INLINE int point() const
Definition: GU_UVFlatten.h:639
SYS_FORCE_INLINE int id() const
Definition: GU_UVFlatten.h:624
ConstraintBundle(const IslandBundle &islands)
Definition: GU_UVFlatten.h:746
const ConstraintSet & islandConstraints(const Island &island) const
Definition: GU_UVFlatten.h:768
ImageBuf OIIO_API flatten(const ImageBuf &src, ROI roi={}, int nthreads=0)
SYS_FORCE_INLINE int vtxIslandPt(GA_Offset vtx, int island_idx) const
Definition: GU_UVFlatten.h:231
GLdouble angle
Definition: glew.h:9135
exint size() const
Definition: UT_Array.h:451
#define M_PI
Definition: ImathPlatform.h:51
#define GA_INVALID_OFFSET
Definition: GA_Types.h:674
AlignGroupSet & alignedSets()
Definition: GU_UVFlatten.h:726
bool isPrimary(const Island &island) const
Definition: GU_UVFlatten.h:211
GA_Size GA_Offset
Definition: GA_Types.h:637
void parallelForEachIsland(Func func)
Definition: GU_UVFlatten.h:262
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
SYS_FORCE_INLINE int hedgeIsland(GEO_Hedge h) const
Definition: GU_UVFlatten.h:215
bool operator!=(const GroupConstraintList &other) const
Definition: GU_UVFlatten.h:580
GU_API void generateStraighLoopConstraints(const TriMesh &mesh, const ConstraintSet &constraints, AngleConstraintArray &angle_constraints)
AlignInfo(AlignDir dir, int id=-1)
Definition: GU_UVFlatten.h:697
int64 exint
Definition: SYS_Types.h:120
GEO_Hedge encapsulates a half-edge (hedge) which is the restriction of.
Definition: GEO_Hedge.h:47
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:134
void forEachIslandIndex(Func func, bool parallel=false) const
Definition: GU_UVFlatten.h:268
PinInfo(int pt, UT_Vector3R uv, int id=-1, int ref_pt=-1, UT_Vector3R refuv={0, 0, 0})
Definition: GU_UVFlatten.h:632
void forEachDirtyIsland(Func func)
Definition: GU_UVFlatten.h:319
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
SYS_FORCE_INLINE UT_Vector3R refuv() const
Definition: GU_UVFlatten.h:654
GU_API Status flattenLSCM(const TriMesh &mesh, const ConstraintSet &constraints, const GetFunctor< UT_Vector3R > &get_pt_pos, int outer_boundary_comp, const SetFunctor< UT_Vector2R > &set_pt_uv)
ConstraintSet & islandConstraints(const Island &island)
Definition: GU_UVFlatten.h:764
const StraightenGroupSet & straightSets() const
Definition: GU_UVFlatten.h:729
GU_API void calcConformalEnergyData(const TriMesh &mesh, const GetFunctor< UT_Vector3R > &get_pt_pos, UT_FprealArray &hedge_apx_cotan, UT_FprealArray &hedge_tri_area)
SYS_FORCE_INLINE bool operator==(const BaseInfo &other) const
Definition: GU_UVFlatten.h:620
SYS_FORCE_INLINE int vertexPrimaryIsland(GA_Offset vtx) const
Definition: GU_UVFlatten.h:219
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
SYS_FORCE_INLINE bool operator==(const AngleInfo &other) const
Definition: GU_UVFlatten.h:684
std::function< void(int, T)> SetFunctor
Definition: GU_UVUtils.h:29
SYS_FORCE_INLINE UT_Vector3R uv() const
Definition: GU_UVFlatten.h:651
#define GU_API
Definition: GU_API.h:14
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:8011
SYS_FORCE_INLINE const T & first() const
Definition: GU_UVFlatten.h:77
PtrRange(const T *s, const T *e)
Definition: GU_UVFlatten.h:64
GU_API Status flattenSCP(const TriMesh &mesh, const ConstraintSet &constraints, const GetFunctor< UT_Vector3R > &get_pt_pos, int outer_boundary_comp, const SetFunctor< UT_Vector2R > &set_pt_uv)
SYS_FORCE_INLINE int refPoint() const
Definition: GU_UVFlatten.h:642
const AlignGroupSet & alignedSets() const
Definition: GU_UVFlatten.h:725
SYS_FORCE_INLINE bool operator==(const AlignInfo &other) const
Definition: GU_UVFlatten.h:704
StraightenGroupSet & straightSets()
Definition: GU_UVFlatten.h:730
SYS_FORCE_INLINE const T * end() const
Definition: GU_UVFlatten.h:71
GLdouble GLdouble GLdouble b
Definition: glew.h:9122
SYS_FORCE_INLINE ElementRange elements(int i) const
Definition: GU_UVFlatten.h:571
double fpreal
Definition: SYS_Types.h:276
GLenum func
Definition: glcorearb.h:782
void makeDirty(const Island &island)
Definition: GU_UVFlatten.h:349
void parallelForEachDirtyIsland(Func func)
Definition: GU_UVFlatten.h:329
SYS_FORCE_INLINE bool operator==(const PinInfo &pin) const
Definition: GU_UVFlatten.h:657
void forEachDirtyIsland(Func func) const
Definition: GU_UVFlatten.h:299
const PinSet & pins() const
Definition: GU_UVFlatten.h:717
GLdouble GLdouble GLdouble r
Definition: glew.h:1406
SYS_FORCE_INLINE AlignDir dir() const
Definition: GU_UVFlatten.h:701
GU_API int longestBoundaryComponent(const TriMesh &mesh, const GetFunctor< UT_Vector3R > &get_pt_pos)
const AngleSet & angles() const
Definition: GU_UVFlatten.h:721
GU_API Status flattenLinearABF(const TriMesh &mesh, const ConstraintSet &constraints, const GetFunctor< UT_Vector3R > &get_pt_pos, int outer_boundary_comp, const SetFunctor< fpreal > &set_vtx_angle)
Island(const GU_Detail *gdp, int idx=-1, GA_RWHandleI vtx_pt_attr=GA_RWHandleI(), Tessellation tessellation=TRIANGULATE_ALL)
Definition: GU_UVFlatten.h:98
bool operator!=(const ElementConstraintList< T > &other) const
Definition: GU_UVFlatten.h:523
GU_TriangleMeshR::Tessellation Tessellation
Definition: GU_UVFlatten.h:83
SYS_FORCE_INLINE fpreal angle() const
Definition: GU_UVFlatten.h:681
bool operator==(const GroupConstraintList &other) const
Definition: GU_UVFlatten.h:575
SYS_FORCE_INLINE int hedgeIn() const
Definition: GU_UVFlatten.h:675
GU_API Status flattenProjection(const TriMesh &mesh, const GetFunctor< UT_Vector3R > &get_pt_pos, const SetFunctor< UT_Vector2R > &set_pt_uv)
const GEO_DetachedHedgeInterface HedgeInterface
Definition: GU_Decompose.h:54
AngleInfo(int i_in, int i_out, fpreal angle=M_PI)
Definition: GU_UVFlatten.h:670
SYS_FORCE_INLINE exint size() const
Definition: GU_UVFlatten.h:74
SYS_FORCE_INLINE ElementRange elements() const
Definition: GU_UVFlatten.h:553
GA_RWHandleT< int32 > GA_RWHandleI
Definition: GA_Handle.h:1254
SYS_FORCE_INLINE const T & data() const
Definition: GU_UVFlatten.h:557
#define SYSmin(a, b)
Definition: SYS_Math.h:1448
SYS_FORCE_INLINE const T * begin() const
Definition: GU_UVFlatten.h:68
Declare prior to use.
SYS_FORCE_INLINE GroupHandle operator()(int i) const
Definition: GU_UVFlatten.h:567
bool operator!=(const ConstraintSet &other) const
Definition: GU_UVFlatten.h:611
void forEachIsland(Func func)
Definition: GU_UVFlatten.h:256