Blender V2.61 - r43446
|
00001 #ifndef BLI_GRAPH_H_ 00002 #define BLI_GRAPH_H_ 00003 00008 #include "DNA_listBase.h" 00009 00010 struct BGraph; 00011 struct BNode; 00012 struct BArc; 00013 00014 struct RadialArc; 00015 00016 typedef void (*FreeArc)(struct BArc*); 00017 typedef void (*FreeNode)(struct BNode*); 00018 typedef void (*RadialSymmetry)(struct BNode* root_node, struct RadialArc* ring, int total); 00019 typedef void (*AxialSymmetry)(struct BNode* root_node, struct BNode* node1, struct BNode* node2, struct BArc* arc1, struct BArc* arc2); 00020 00021 /* IF YOU MODIFY THOSE TYPES, YOU NEED TO UPDATE ALL THOSE THAT "INHERIT" FROM THEM 00022 * 00023 * RigGraph, ReebGraph 00024 * 00025 * */ 00026 00027 typedef struct BGraph { 00028 ListBase arcs; 00029 ListBase nodes; 00030 00031 float length; 00032 00033 /* function pointer to deal with custom fonctionnality */ 00034 FreeArc free_arc; 00035 FreeNode free_node; 00036 RadialSymmetry radial_symmetry; 00037 AxialSymmetry axial_symmetry; 00038 } BGraph; 00039 00040 typedef struct BNode { 00041 void *next, *prev; 00042 float p[3]; 00043 int flag; 00044 00045 int degree; 00046 struct BArc **arcs; 00047 00048 int subgraph_index; 00049 00050 int symmetry_level; 00051 int symmetry_flag; 00052 float symmetry_axis[3]; 00053 } BNode; 00054 00055 typedef struct BArc { 00056 void *next, *prev; 00057 struct BNode *head, *tail; 00058 int flag; 00059 00060 float length; 00061 00062 int symmetry_level; 00063 int symmetry_group; 00064 int symmetry_flag; 00065 } BArc; 00066 00067 struct BArcIterator; 00068 00069 void* IT_head(void* iter); 00070 void* IT_tail(void* iter); 00071 void* IT_peek(void* iter, int n); 00072 void* IT_next(void* iter); 00073 void* IT_nextN(void* iter, int n); 00074 void* IT_previous(void* iter); 00075 int IT_stopped(void* iter); 00076 00077 typedef void* (*HeadFct)(void* iter); 00078 typedef void* (*TailFct)(void* iter); 00079 typedef void* (*PeekFct)(void* iter, int n); 00080 typedef void* (*NextFct)(void* iter); 00081 typedef void* (*NextNFct)(void* iter, int n); 00082 typedef void* (*PreviousFct)(void* iter); 00083 typedef int (*StoppedFct)(void* iter); 00084 00085 typedef struct BArcIterator { 00086 HeadFct head; 00087 TailFct tail; 00088 PeekFct peek; 00089 NextFct next; 00090 NextNFct nextN; 00091 PreviousFct previous; 00092 StoppedFct stopped; 00093 00094 float *p, *no; 00095 float size; 00096 00097 int length; 00098 int index; 00099 } BArcIterator; 00100 00101 /* Helper structure for radial symmetry */ 00102 typedef struct RadialArc 00103 { 00104 struct BArc *arc; 00105 float n[3]; /* normalized vector joining the nodes of the arc */ 00106 } RadialArc; 00107 00108 BNode *BLI_otherNode(BArc *arc, BNode *node); 00109 00110 void BLI_freeNode(BGraph *graph, BNode *node); 00111 void BLI_removeNode(BGraph *graph, BNode *node); 00112 00113 void BLI_removeArc(BGraph *graph, BArc *arc); 00114 00115 void BLI_flagNodes(BGraph *graph, int flag); 00116 void BLI_flagArcs(BGraph *graph, int flag); 00117 00118 int BLI_hasAdjacencyList(BGraph *rg); 00119 void BLI_buildAdjacencyList(BGraph *rg); 00120 void BLI_rebuildAdjacencyList(BGraph* rg); 00121 void BLI_rebuildAdjacencyListForNode(BGraph* rg, BNode *node); 00122 void BLI_freeAdjacencyList(BGraph *rg); 00123 00124 int BLI_FlagSubgraphs(BGraph *graph); 00125 void BLI_ReflagSubgraph(BGraph *graph, int old_subgraph, int new_subgraph); 00126 00127 #define SHAPE_RADIX 10 /* each shape level is encoded this base */ 00128 00129 int BLI_subtreeShape(BGraph *graph, BNode *node, BArc *rootArc, int include_root); 00130 float BLI_subtreeLength(BNode *node); 00131 void BLI_calcGraphLength(BGraph *graph); 00132 00133 void BLI_replaceNode(BGraph *graph, BNode *node_src, BNode *node_replaced); 00134 void BLI_replaceNodeInArc(BGraph *graph, BArc *arc, BNode *node_src, BNode *node_replaced); 00135 void BLI_removeDoubleNodes(BGraph *graph, float limit); 00136 BNode * BLI_FindNodeByPosition(BGraph *graph, float *p, float limit); 00137 00138 BArc * BLI_findConnectedArc(BGraph *graph, BArc *arc, BNode *v); 00139 00140 int BLI_isGraphCyclic(BGraph *graph); 00141 00142 /*------------ Symmetry handling ------------*/ 00143 void BLI_markdownSymmetry(BGraph *graph, BNode *root_node, float limit); 00144 00145 void BLI_mirrorAlongAxis(float v[3], float center[3], float axis[3]); 00146 00147 /* BNode symmetry flags */ 00148 #define SYM_TOPOLOGICAL 1 00149 #define SYM_PHYSICAL 2 00150 00151 /* the following two are exclusive */ 00152 #define SYM_AXIAL 4 00153 #define SYM_RADIAL 8 00154 00155 /* BArc symmetry flags 00156 * 00157 * axial symetry sides */ 00158 #define SYM_SIDE_POSITIVE 1 00159 #define SYM_SIDE_NEGATIVE 2 00160 /* Anything higher is the order in radial symmetry */ 00161 #define SYM_SIDE_RADIAL 3 00162 00163 #endif /*BLI_GRAPH_H_*/