31
33
#include "DNA_listBase.h"
35
#include "BLI_graph.h"
38
43
typedef struct ReebGraph {
51
RadialSymmetry radial_symmetry;
52
AxialSymmetry axial_symmetry;
53
/*********************************/
42
57
struct EdgeHash *emap;
59
struct ReebGraph *link_up; /* for multi resolution filtering, points to higher levels */
45
62
typedef struct EmbedBucket {
66
float no[3]; /* if non-null, normal of the bucket */
51
69
typedef struct ReebNode {
52
struct ReebNode *next, *prev;
53
75
struct ReebArc **arcs;
81
float symmetry_axis[3];
82
/*********************************/
89
struct ReebNode *link_down; /* for multi resolution filtering, points to lower levels, if present */
90
struct ReebNode *link_up;
61
93
typedef struct ReebEdge {
63
95
struct ReebArc *arc;
64
96
struct ReebNode *v1, *v2;
65
97
struct ReebEdge *nextEdge;
68
101
typedef struct ReebArc {
69
struct ReebArc *next, *prev;
103
struct ReebNode *head, *tail;
111
/*********************************/
71
struct ReebNode *v1, *v2;
72
115
struct EmbedBucket *buckets;
119
struct ReebArc *link_up; /* for multi resolution filtering, points to higher levels */
77
122
typedef struct ReebArcIterator {
128
PreviousFct previous;
135
/*********************************/
78
136
struct ReebArc *arc;
83
140
} ReebArcIterator;
87
int weightToHarmonic(struct EditMesh *em);
88
int weightFromDistance(struct EditMesh *em);
145
int weightToHarmonic(struct EditMesh *em, struct EdgeIndex *indexed_edges);
146
int weightFromDistance(struct EditMesh *em, struct EdgeIndex *indexed_edges);
89
147
int weightFromLoc(struct EditMesh *me, int axis);
90
void weightToVCol(struct EditMesh *em);
148
void weightToVCol(struct EditMesh *em, int index);
149
void arcToVCol(struct ReebGraph *rg, struct EditMesh *em, int index);
150
void angleToVCol(struct EditMesh *em, int index);
91
151
void renormalizeWeight(struct EditMesh *em, float newmax);
93
153
ReebGraph * generateReebGraph(struct EditMesh *me, int subdivisions);
94
void freeGraph(ReebGraph *rg);
95
void exportGraph(ReebGraph *rg, int count);
97
#define OTHER_NODE(arc, node) ((arc->v1 == node) ? arc->v2 : arc->v1)
99
void initArcIterator(struct ReebArcIterator *iter, struct ReebArc *arc, struct ReebNode *head);
100
void initArcIterator2(struct ReebArcIterator *iter, struct ReebArc *arc, int start, int end);
101
struct EmbedBucket * nextBucket(struct ReebArcIterator *iter);
154
ReebGraph * newReebGraph();
156
void initArcIterator(BArcIterator *iter, struct ReebArc *arc, struct ReebNode *head);
157
void initArcIterator2(BArcIterator *iter, struct ReebArc *arc, int start, int end);
158
void initArcIteratorStart(BArcIterator *iter, struct ReebArc *arc, struct ReebNode *head, int start);
104
161
void filterNullReebGraph(ReebGraph *rg);
162
int filterSmartReebGraph(ReebGraph *rg, float threshold);
105
163
int filterExternalReebGraph(ReebGraph *rg, float threshold);
106
164
int filterInternalReebGraph(ReebGraph *rg, float threshold);
110
168
void postprocessGraph(ReebGraph *rg, char mode);
111
169
void removeNormalNodes(ReebGraph *rg);
113
/* Graph processing */
114
void buildAdjacencyList(ReebGraph *rg);
116
171
void sortNodes(ReebGraph *rg);
117
172
void sortArcs(ReebGraph *rg);
119
int subtreeDepth(ReebNode *node, ReebArc *rootArc);
120
int countConnectedArcs(ReebGraph *rg, ReebNode *node);
121
int hasAdjacencyList(ReebGraph *rg);
122
int isGraphCyclic(ReebGraph *rg);
174
/*------------ Sanity check ------------*/
125
175
void verifyBuckets(ReebGraph *rg);
176
void verifyFaces(ReebGraph *rg);
178
/*********************** PUBLIC *********************************/
180
#define REEB_MAX_MULTI_LEVEL 10
182
ReebGraph *BIF_ReebGraphFromEditMesh(void);
183
ReebGraph *BIF_ReebGraphMultiFromEditMesh(void);
184
void BIF_flagMultiArcs(ReebGraph *rg, int flag);
186
void BIF_GlobalReebGraphFromEditMesh(void);
187
void BIF_GlobalReebFree(void);
189
ReebNode *BIF_otherNodeFromIndex(ReebArc *arc, ReebNode *node);
190
ReebNode *BIF_NodeFromIndex(ReebArc *arc, ReebNode *node);
191
ReebNode *BIF_lowestLevelNode(ReebNode *node);
193
ReebGraph *BIF_graphForMultiNode(ReebGraph *rg, ReebNode *node);
195
void REEB_freeGraph(ReebGraph *rg);
196
void REEB_freeArc(BArc *barc);
197
void REEB_exportGraph(ReebGraph *rg, int count);
127
201
#endif /*REEB_H_*/