Welcome to mirror list, hosted at ThFree Co, Russian Federation.

reeb.h « armature « editors « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7297f25c9806a8adccd572c7cc53f8909ced2b86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/*
 * ***** BEGIN GPL LICENSE BLOCK *****
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * Contributor(s): Martin Poirier
 *
 * ***** END GPL LICENSE BLOCK *****
 */

/** \file blender/editors/armature/reeb.h
 *  \ingroup edarmature
 */

 
#ifndef __REEB_H__
#define __REEB_H__

#define WITH_BF_REEB

#include "DNA_listBase.h"

#include "BLI_graph.h"

struct GHash;
struct EdgeHash;
struct ReebArc;
struct ReebEdge;
struct ReebNode;

typedef struct ReebGraph {
	ListBase arcs;
	ListBase nodes;
	
	float length;
	
	FreeArc         free_arc;
	FreeNode        free_node;
	RadialSymmetry  radial_symmetry;
	AxialSymmetry   axial_symmetry;
	/*********************************/
	
	int resolution;
	int totnodes;
	struct EdgeHash *emap;
	int multi_level;
	struct ReebGraph *link_up; /* for multi resolution filtering, points to higher levels */
} ReebGraph;

typedef struct EmbedBucket {
	float val;
	int nv;
	float p[3];
	float no[3]; /* if non-null, normal of the bucket */
} EmbedBucket;

typedef struct ReebNode {
	void *next, *prev;
	float p[3];
	int flag;

	int degree;
	struct ReebArc **arcs;

	int subgraph_index;

	int symmetry_level;
	int symmetry_flag;
	float symmetry_axis[3];
	/*********************************/
	
	float no[3];

	int index;
	float weight;
	int multi_level;
	struct ReebNode *link_down; /* for multi resolution filtering, points to lower levels, if present */
	struct ReebNode *link_up;
} ReebNode;

typedef struct ReebEdge {
	struct ReebEdge *next, *prev;
	struct ReebArc  *arc;
	struct ReebNode *v1, *v2;
	struct ReebEdge *nextEdge;
	int flag;
} ReebEdge;

typedef struct ReebArc {
	void *next, *prev;
	struct ReebNode *head, *tail;
	int flag;

	float length;

	int symmetry_level;
	int symmetry_group;
	int symmetry_flag;
	/*********************************/

	ListBase edges;
	int bcount;
	struct EmbedBucket *buckets;

	struct GHash *faces;
	float angle;
	struct ReebArc *link_up; /* for multi resolution filtering, points to higher levels */
} ReebArc;

typedef struct ReebArcIterator {
	HeadFct      head;
	TailFct      tail;
	PeekFct      peek;
	NextFct      next;
	NextNFct     nextN;
	PreviousFct  previous;
	StoppedFct   stopped;
	
	float *p, *no;
	float size;
	
	int length;
	int index;
	/*********************************/
	struct ReebArc *arc;
	int start;
	int end;
	int stride;
} ReebArcIterator;

#if 0
struct EditMesh;
struct EdgeIndex;

int weightToHarmonic(struct EditMesh *em, struct EdgeIndex *indexed_edges);
int weightFromDistance(struct EditMesh *em, struct EdgeIndex *indexed_edges);
int weightFromLoc(struct EditMesh *me, int axis);
//void weightToVCol(struct EditMesh *em, int index);
void arcToVCol(struct ReebGraph *rg, struct EditMesh *em, int index);
//void angleToVCol(struct EditMesh *em, int index);
void renormalizeWeight(struct EditMesh *em, float newmax);

ReebGraph *generateReebGraph(struct EditMesh *me, int subdivisions);
#endif

ReebGraph *newReebGraph(void);

void initArcIterator(BArcIterator *iter, struct ReebArc *arc, struct ReebNode *head);
void initArcIterator2(BArcIterator *iter, struct ReebArc *arc, int start, int end);
void initArcIteratorStart(BArcIterator *iter, struct ReebArc *arc, struct ReebNode *head, int start);

/* Filtering */
void filterNullReebGraph(ReebGraph *rg);
int filterSmartReebGraph(ReebGraph *rg, float threshold);

/* Post-Build processing */
void repositionNodes(ReebGraph *rg);
void postprocessGraph(ReebGraph *rg, char mode);
void removeNormalNodes(ReebGraph *rg);

void sortNodes(ReebGraph *rg);
void sortArcs(ReebGraph *rg);

/*------------ Sanity check ------------*/
void verifyBuckets(ReebGraph *rg);
void verifyFaces(ReebGraph *rg);
void verifyArcs(ReebGraph *rg);
void verifyNodeDegree(ReebGraph *rg);

/*********************** PUBLIC *********************************/

#define REEB_MAX_MULTI_LEVEL  10

struct bContext;

ReebGraph *BIF_ReebGraphFromEditMesh(void);
ReebGraph *BIF_ReebGraphMultiFromEditMesh(struct bContext *C);
void BIF_flagMultiArcs(ReebGraph *rg, int flag);

void BIF_GlobalReebGraphFromEditMesh(void);
void BIF_GlobalReebFree(void);

ReebNode *BIF_otherNodeFromIndex(ReebArc *arc, ReebNode *node);
ReebNode *BIF_NodeFromIndex(ReebArc *arc, ReebNode *node);
ReebNode *BIF_lowestLevelNode(ReebNode *node);

ReebGraph *BIF_graphForMultiNode(ReebGraph *rg, ReebNode *node);

void REEB_freeGraph(ReebGraph *rg);
void REEB_freeArc(BArc *barc);
void REEB_exportGraph(ReebGraph *rg, int count);
void REEB_draw(void);


#endif /*__REEB_H__*/