HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GU_AutoSeam.h
Go to the documentation of this file.
1 
2 #ifndef __GU_AutoSeam_h__
3 #define __GU_AutoSeam_h__
4 
5 #include "GU_API.h"
6 #include "GU_Detail.h"
7 #include <GA/GA_Edge.h>
8 #include <GA/GA_EdgeGroup.h>
9 #include <UT/UT_StringStream.h>
10 #include <UT/UT_Map.h>
11 #include <GEO/GEO_HedgeInterface.h>
13 #include <UT/UT_SparseMatrix.h>
14 
15 class UT_Classifier;
16 
17 #define USE_EIGEN
18 #define USE_SPECTRA
19 
20 #define PROJECTED_INITIAL_VALUES 0
21 
22 #define AutoSeam
23 
24 
25 class UT_AutoInterrupt;
26 
28 {
29 public:
30  GU_AutoSeam(GU_Detail *gdp, int eigen, fpreal planarity,
31  bool area_weight, GA_EdgeGroup *seams);
32 
34  GA_EdgeGroup* spectralSegment();
35 
36 
37 
38  struct Region
39  {
40  public:
41  Region(GA_OffsetArray &prims, int index, fpreal dist);
42  Region(int index, fpreal dist);
43 
44  GA_OffsetArray& getRegionPrimitives() { return myPrimitives; }
45  void appendPrimitive(GA_Offset prim) { myPrimitives.append(prim); }
46  fpreal getDistortion() { return myDistortion; }
47  int getRegionNumber() { return myRegionNumber; }
48 
49 
50  private:
51  int myRegionNumber;
52  GA_OffsetArray myPrimitives;
53  fpreal myDistortion;
54  //GU_Detail *myGdp;
55  };
56 
57 #if 0
58  struct Border
59  {
60  private:
61  int myRegion1Ind;
62  int myRegion2Ind;
63  fpreal myMergeCost;
64  };
65 #endif
66 
68 
70  {
71  int ind = 0;
72  while (ind < myNumRegions
73  && region->getDistortion() < myOrderedRegions(ind)->getDistortion())
74  ++ind;
75 
76  myOrderedRegions.insert(region, ind);
77  ++myNumRegions;
78  }
79 
80  void popRegion() { delete (myOrderedRegions(0));
81  myOrderedRegions.removeIndex(0);
82  --myNumRegions;}
83 
84  void indexDualVertices(UT_Array<exint> &dual_vert_index, GA_OffsetArray &prims);
85 
86  void tripletsOfLaplacian(UT_Array<UT_SparseMatrixCSRD::Triplet> &lap_entries,
87  UT_Array<exint> &dual_vert_index, GA_OffsetArray &prims);
88 
89  void graphCut(GA_OffsetArray &prims);
90 
91  bool checkConnected(GA_OffsetArray &prims);
92  void checkConnectedHelp(GA_Offset prim, UT_BitArray &mark, UT_BitArray &seen,
94 
95  void addCuts(UT_VectorD &v, UT_Array<exint> &dual_vert_index,
96  GA_OffsetArray &prims);
97 
98  fpreal cutLength(UT_VectorD &v, GA_OffsetArray &seams,
99  UT_Array<exint> &dual_vert_index,
100  GA_OffsetArray &prims);
101 
102  void partitionPrims(UT_VectorD &v, UT_Array<exint> &dual_vert_index,
103  GA_OffsetArray &prims, GA_OffsetArray &region1,
104  GA_OffsetArray &region2, int &reg1_ind, int &reg2_ind,
105  bool assign_region = true);
106 
107  void partitionPrims(UT_VectorD &v, UT_Array<exint> &dual_vert_index,
108  GA_OffsetArray &prims, GA_OffsetArray &region1,
109  GA_OffsetArray &region2,
110  bool assign_region = true);
111 
112  void displayRegions(UT_VectorD &v, UT_Array<exint> &dual_vert_index,
113  GA_OffsetArray &prims);
114  void displayRegions(UT_Array<exint> &dual_vert_index);
115  void displayRegions();
116 
117  bool isBoundary(GEO_Hedge h);
118 
120  *getInputHedgeInterface();
121 
127  RegionArray myOrderedRegions; // ordered by non-planarity
134  bool myRecurse;
136  bool myNormLap;
137  bool myDontPD;
141 
142  GA_VertexGroup *mySeamHedgeSrcs = nullptr;
143 
144 
145  // Maps a vertex offset to a virtual point number for the
146  // cut island topology. This way, vertices along island boundaries
147  // will have different point numbers based on the sides of the cuts they
148  // lie on.
149 
151 };
152 #endif
UT_ExintArray myVirtualPtNum
Definition: GU_AutoSeam.h:150
GA_API const UT_StringHolder dist
const GLdouble * v
Definition: glcorearb.h:836
UT_Array< int > myRegionNumbers
Definition: GU_AutoSeam.h:124
bool myNormLap
Definition: GU_AutoSeam.h:136
void addRegionToOrderedRegions(Region *region)
Definition: GU_AutoSeam.h:69
UT_Array< Region * > RegionArray
Definition: GU_AutoSeam.h:67
fpreal myPlanarity
Definition: GU_AutoSeam.h:130
RegionArray myOrderedRegions
Definition: GU_AutoSeam.h:127
void appendPrimitive(GA_Offset prim)
Definition: GU_AutoSeam.h:45
GA_Size GA_Offset
Definition: GA_Types.h:617
GA_EdgeGroup * mySeams
Definition: GU_AutoSeam.h:140
int myEigenNumber
Definition: GU_AutoSeam.h:129
GEO_DetachedHedgeInterface * myHI
Definition: GU_AutoSeam.h:123
GEO_Hedge encapsulates a half-edge (hedge) which is the restriction of.
Definition: GEO_Hedge.h:47
bool myUseMedian
Definition: GU_AutoSeam.h:138
GA_OffsetArray & getRegionPrimitives()
Definition: GU_AutoSeam.h:44
bool myOnlyFiedler
Definition: GU_AutoSeam.h:133
#define GU_API
Definition: GU_API.h:11
void popRegion()
Definition: GU_AutoSeam.h:80
bool myRecurse
Definition: GU_AutoSeam.h:134
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
double fpreal
Definition: SYS_Types.h:263
int myNumRecurse
Definition: GU_AutoSeam.h:135
GLuint index
Definition: glcorearb.h:785
bool myAreaWeighted
Definition: GU_AutoSeam.h:131
UT_BitArray myIsCutSrc
Definition: GU_AutoSeam.h:125
fpreal getDistortion()
Definition: GU_AutoSeam.h:46
GU_Detail * myGdp
Definition: GU_AutoSeam.h:126
int myNumRegions
Definition: GU_AutoSeam.h:128