4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * Contributor(s): Martin Poirier
22 * ***** END GPL LICENSE BLOCK *****
30 #include "DNA_listBase.h"
32 #include "BLI_graph.h"
40 typedef struct ReebGraph {
48 RadialSymmetry radial_symmetry;
49 AxialSymmetry axial_symmetry;
50 /*********************************/
54 struct EdgeHash *emap;
56 struct ReebGraph *link_up; /* for multi resolution filtering, points to higher levels */
59 typedef struct EmbedBucket {
63 float no[3]; /* if non-null, normal of the bucket */
66 typedef struct ReebNode {
72 struct ReebArc **arcs;
78 float symmetry_axis[3];
79 /*********************************/
86 struct ReebNode *link_down; /* for multi resolution filtering, points to lower levels, if present */
87 struct ReebNode *link_up;
90 typedef struct ReebEdge {
91 struct ReebEdge *next, *prev;
93 struct ReebNode *v1, *v2;
94 struct ReebEdge *nextEdge;
98 typedef struct ReebArc {
100 struct ReebNode *head, *tail;
108 /*********************************/
112 struct EmbedBucket *buckets;
116 struct ReebArc *link_up; /* for multi resolution filtering, points to higher levels */
119 typedef struct ReebArcIterator {
125 PreviousFct previous;
133 /*********************************/
143 int weightToHarmonic(struct EditMesh *em, struct EdgeIndex *indexed_edges);
144 int weightFromDistance(struct EditMesh *em, struct EdgeIndex *indexed_edges);
145 int weightFromLoc(struct EditMesh *me, int axis);
146 void weightToVCol(struct EditMesh *em, int index);
147 void arcToVCol(struct ReebGraph *rg, struct EditMesh *em, int index);
148 void angleToVCol(struct EditMesh *em, int index);
149 void renormalizeWeight(struct EditMesh *em, float newmax);
151 ReebGraph * generateReebGraph(struct EditMesh *me, int subdivisions);
152 ReebGraph * newReebGraph();
154 void initArcIterator(BArcIterator *iter, struct ReebArc *arc, struct ReebNode *head);
155 void initArcIterator2(BArcIterator *iter, struct ReebArc *arc, int start, int end);
156 void initArcIteratorStart(BArcIterator *iter, struct ReebArc *arc, struct ReebNode *head, int start);
159 void filterNullReebGraph(ReebGraph *rg);
160 int filterSmartReebGraph(ReebGraph *rg, float threshold);
161 int filterExternalReebGraph(ReebGraph *rg, float threshold);
162 int filterInternalReebGraph(ReebGraph *rg, float threshold);
164 /* Post-Build processing */
165 void repositionNodes(ReebGraph *rg);
166 void postprocessGraph(ReebGraph *rg, char mode);
167 void removeNormalNodes(ReebGraph *rg);
169 void sortNodes(ReebGraph *rg);
170 void sortArcs(ReebGraph *rg);
172 /*------------ Sanity check ------------*/
173 void verifyBuckets(ReebGraph *rg);
174 void verifyFaces(ReebGraph *rg);
176 /*********************** PUBLIC *********************************/
178 #define REEB_MAX_MULTI_LEVEL 10
182 ReebGraph *BIF_ReebGraphFromEditMesh(void);
183 ReebGraph *BIF_ReebGraphMultiFromEditMesh(struct bContext *C);
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);