Blender V2.61 - r43446
Classes | Defines | Typedefs | Enumerations | Functions

reeb.c File Reference

#include <math.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <float.h>
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "MEM_guardedalloc.h"
#include "BKE_context.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLI_editVert.h"
#include "BLI_edgehash.h"
#include "BLI_ghash.h"
#include "BLI_heap.h"
#include "ONL_opennl.h"
#include "reeb.h"

Go to the source code of this file.

Classes

struct  VertexData
struct  EdgeIndex

Defines

#define DEBUG_REEB
#define DEBUG_REEB_NODE

Typedefs

typedef struct VertexData VertexData
typedef struct EdgeIndex EdgeIndex

Enumerations

enum  MergeDirection { MERGE_LOWER, MERGE_HIGHER, MERGE_APPEND }

Functions

int mergeArcs (ReebGraph *rg, ReebArc *a0, ReebArc *a1)
void mergeArcEdges (ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection direction)
int mergeConnectedArcs (ReebGraph *rg, ReebArc *a0, ReebArc *a1)
EditEdgeNextEdgeForVert (EdgeIndex *indexed_edges, int index)
void mergeArcFaces (ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc)
void addFacetoArc (ReebArc *arc, EditFace *efa)
void REEB_RadialSymmetry (BNode *root_node, RadialArc *ring, int count)
void REEB_AxialSymmetry (BNode *root_node, BNode *node1, BNode *node2, struct BArc *barc1, BArc *barc2)
void flipArcBuckets (ReebArc *arc)
static VertexDataallocVertexData (EditMesh *em)
static int indexData (EditVert *eve)
static float weightData (EditVert *eve)
static void weightSetData (EditVert *eve, float w)
static ReebNodenodeData (EditVert *eve)
static void nodeSetData (EditVert *eve, ReebNode *n)
void REEB_freeArc (BArc *barc)
void REEB_freeGraph (ReebGraph *rg)
ReebGraphnewReebGraph (void)
void BIF_flagMultiArcs (ReebGraph *rg, int flag)
static ReebNodeaddNode (ReebGraph *rg, EditVert *eve)
static ReebNodecopyNode (ReebGraph *rg, ReebNode *node)
static void relinkNodes (ReebGraph *low_rg, ReebGraph *high_rg)
ReebNodeBIF_otherNodeFromIndex (ReebArc *arc, ReebNode *node)
ReebNodeBIF_NodeFromIndex (ReebArc *arc, ReebNode *node)
ReebNodeBIF_lowestLevelNode (ReebNode *node)
static ReebArccopyArc (ReebGraph *rg, ReebArc *arc)
static ReebGraphcopyReebGraph (ReebGraph *rg, int level)
ReebGraphBIF_graphForMultiNode (ReebGraph *rg, ReebNode *node)
static ReebEdgecopyEdge (ReebEdge *edge)
static void printArc (ReebArc *arc)
static void flipArc (ReebArc *arc)
static void NodeDegreeDecrement (ReebGraph *UNUSED(rg), ReebNode *node)
static void NodeDegreeIncrement (ReebGraph *UNUSED(rg), ReebNode *node)
void repositionNodes (ReebGraph *rg)
void verifyNodeDegree (ReebGraph *rg)
static void verifyBucketsArc (ReebGraph *UNUSED(rg), ReebArc *arc)
void verifyBuckets (ReebGraph *rg)
void verifyFaces (ReebGraph *rg)
void verifyArcs (ReebGraph *rg)
static void verifyMultiResolutionLinks (ReebGraph *rg, int level)
static void addVertToBucket (EmbedBucket *b, float co[3])
static void mergeBuckets (EmbedBucket *bDst, EmbedBucket *bSrc)
static void mergeArcBuckets (ReebArc *aDst, ReebArc *aSrc, float start, float end)
static int countArcBuckets (ReebArc *arc)
static void allocArcBuckets (ReebArc *arc)
static void resizeArcBuckets (ReebArc *arc)
static void reweightBuckets (ReebArc *arc)
static void interpolateBuckets (ReebArc *arc, float *start_p, float *end_p, int start_index, int end_index)
static void fillArcEmptyBuckets (ReebArc *arc)
static void ExtendArcBuckets (ReebArc *arc)
static void extendGraphBuckets (ReebGraph *rg)
static void calculateArcLength (ReebArc *arc)
static void calculateGraphLength (ReebGraph *rg)
void postprocessGraph (ReebGraph *rg, char mode)
static int compareNodesWeight (void *vnode1, void *vnode2)
void sortNodes (ReebGraph *rg)
static int compareArcsWeight (void *varc1, void *varc2)
void sortArcs (ReebGraph *rg)
static void reweightArc (ReebGraph *rg, ReebArc *arc, ReebNode *start_node, float start_weight)
static void reweightSubgraph (ReebGraph *rg, ReebNode *start_node, float start_weight)
static int joinSubgraphsEnds (ReebGraph *rg, float threshold, int nb_subgraphs)
static void fixSubgraphsOrientation (ReebGraph *rg, int nb_subgraphs)
static int joinSubgraphs (ReebGraph *rg, float threshold)
static float lengthArc (ReebArc *arc)
static int compareArcs (void *varc1, void *varc2)
static void filterArc (ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, ReebArc *srcArc, int merging)
void filterNullReebGraph (ReebGraph *rg)
static int filterInternalExternalReebGraph (ReebGraph *rg, float threshold_internal, float threshold_external)
static int filterCyclesReebGraph (ReebGraph *rg, float UNUSED(distance_threshold))
int filterSmartReebGraph (ReebGraph *UNUSED(rg), float UNUSED(threshold))
static void filterGraph (ReebGraph *rg, short options, float threshold_internal, float threshold_external)
static void finalizeGraph (ReebGraph *rg, char passes, char method)
static int compareVerts (const void *a, const void *b)
static void spreadWeight (EditMesh *em)
static void exportNode (FILE *f, const char *text, ReebNode *node)
void REEB_exportGraph (ReebGraph *rg, int count)
static void removeZeroNodes (ReebGraph *rg)
void removeNormalNodes (ReebGraph *rg)
static int edgeEquals (ReebEdge *e1, ReebEdge *e2)
static ReebArcnextArcMappedToEdge (ReebArc *arc, ReebEdge *e)
void mergeArcFaces (ReebGraph *UNUSED(rg), ReebArc *aDst, ReebArc *aSrc)
static void glueByMergeSort (ReebGraph *rg, ReebArc *a0, ReebArc *a1, ReebEdge *e0, ReebEdge *e1)
static void mergePaths (ReebGraph *rg, ReebEdge *e0, ReebEdge *e1, ReebEdge *e2)
static ReebEdgecreateArc (ReebGraph *rg, ReebNode *node1, ReebNode *node2)
static void addTriangleToGraph (ReebGraph *rg, ReebNode *n1, ReebNode *n2, ReebNode *n3, EditFace *efa)
ReebGraphgenerateReebGraph (EditMesh *em, int subdivisions)
void renormalizeWeight (EditMesh *em, float newmax)
int weightFromLoc (EditMesh *em, int axis)
static float cotan_weight (float *v1, float *v2, float *v3)
static void addTriangle (EditVert *v1, EditVert *v2, EditVert *v3, int e1, int e2, int e3)
int weightToHarmonic (EditMesh *em, EdgeIndex *indexed_edges)
static void shortestPathsFromVert (EditMesh *em, EditVert *starting_vert, EdgeIndex *indexed_edges)
static void freeEdgeIndex (EdgeIndex *indexed_edges)
static void buildIndexedEdges (EditMesh *em, EdgeIndex *indexed_edges)
int weightFromDistance (EditMesh *em, EdgeIndex *indexed_edges)
static void * headNode (void *arg)
static void * tailNode (void *arg)
static void * nextBucket (void *arg)
static void * nextNBucket (void *arg, int n)
static void * peekBucket (void *arg, int n)
static void * previousBucket (void *arg)
static int iteratorStopped (void *arg)
static void initIteratorFct (ReebArcIterator *iter)
static void setIteratorValues (ReebArcIterator *iter, EmbedBucket *bucket)
void initArcIterator (BArcIterator *arg, ReebArc *arc, ReebNode *head)
void initArcIteratorStart (BArcIterator *arg, struct ReebArc *arc, struct ReebNode *head, int start)
void initArcIterator2 (BArcIterator *arg, ReebArc *arc, int start, int end)
ReebGraphBIF_ReebGraphMultiFromEditMesh (bContext *C)

Detailed Description

Definition in file reeb.c.


Define Documentation

#define DEBUG_REEB

Definition at line 80 of file reeb.c.

#define DEBUG_REEB_NODE

Definition at line 81 of file reeb.c.


Typedef Documentation

typedef struct EdgeIndex EdgeIndex
typedef struct VertexData VertexData

Enumeration Type Documentation

Enumerator:
MERGE_LOWER 
MERGE_HIGHER 
MERGE_APPEND 

Definition at line 96 of file reeb.c.


Function Documentation

void addFacetoArc ( ReebArc arc,
EditFace efa 
)

Definition at line 2181 of file reeb.c.

References BLI_ghash_insert(), and ReebArc::faces.

Referenced by addTriangleToGraph().

static ReebNode* addNode ( ReebGraph rg,
EditVert eve 
) [static]
static void addTriangle ( EditVert v1,
EditVert v2,
EditVert v3,
int  e1,
int  e2,
int  e3 
) [static]

Definition at line 2697 of file reeb.c.

References EditVert::co, cotan_weight(), indexData(), and nlMatrixAdd().

Referenced by weightToHarmonic().

static void addTriangleToGraph ( ReebGraph rg,
ReebNode n1,
ReebNode n2,
ReebNode n3,
EditFace efa 
) [static]

Definition at line 2504 of file reeb.c.

References addFacetoArc(), ReebEdge::arc, createArc(), fabs(), mergePaths(), ReebEdge::v1, and ReebNode::weight.

Referenced by generateReebGraph().

static void addVertToBucket ( EmbedBucket b,
float  co[3] 
) [static]

Definition at line 623 of file reeb.c.

References interp_v3_v3v3(), EmbedBucket::nv, and EmbedBucket::p.

Referenced by createArc().

static void allocArcBuckets ( ReebArc arc) [static]
static VertexData* allocVertexData ( EditMesh em) [static]
void BIF_flagMultiArcs ( ReebGraph rg,
int  flag 
)

Definition at line 226 of file reeb.c.

References BLI_flagArcs(), and ReebGraph::link_up.

Referenced by retargetGraphs().

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

Definition at line 313 of file reeb.c.

References ReebNode::link_down.

ReebNode* BIF_NodeFromIndex ( ReebArc arc,
ReebNode node 
)

Definition at line 308 of file reeb.c.

References ReebArc::head, ReebNode::index, and ReebArc::tail.

Referenced by testFlipArc().

ReebNode* BIF_otherNodeFromIndex ( ReebArc arc,
ReebNode node 
)

Definition at line 303 of file reeb.c.

References ReebArc::head, ReebNode::index, and ReebArc::tail.

Referenced by retargetSubgraph().

ReebGraph* BIF_ReebGraphMultiFromEditMesh ( bContext C)
static void buildIndexedEdges ( EditMesh em,
EdgeIndex indexed_edges 
) [static]
static void calculateArcLength ( ReebArc arc) [static]
static void calculateGraphLength ( ReebGraph rg) [static]

Definition at line 947 of file reeb.c.

References ReebGraph::arcs, calculateArcLength(), ListBase::first, and ReebArc::next.

Referenced by filterGraph().

static int compareArcs ( void *  varc1,
void *  varc2 
) [static]

Definition at line 1475 of file reeb.c.

References lengthArc().

Referenced by filterInternalExternalReebGraph(), and filterSmartReebGraph().

static int compareArcsWeight ( void *  varc1,
void *  varc2 
) [static]

Definition at line 1226 of file reeb.c.

References ReebArc::head, and ReebNode::weight.

Referenced by sortArcs().

static int compareNodesWeight ( void *  vnode1,
void *  vnode2 
) [static]

Definition at line 1202 of file reeb.c.

References ReebNode::weight.

Referenced by sortNodes().

static int compareVerts ( const void *  a,
const void *  b 
) [static]

Definition at line 1965 of file reeb.c.

References weightData().

Referenced by spreadWeight().

static ReebArc* copyArc ( ReebGraph rg,
ReebArc arc 
) [static]
static ReebEdge* copyEdge ( ReebEdge edge) [static]

Definition at line 410 of file reeb.c.

References MEM_callocN(), ReebEdge::next, NULL, and ReebEdge::prev.

Referenced by mergeArcEdges().

static ReebNode* copyNode ( ReebGraph rg,
ReebNode node 
) [static]
static ReebGraph* copyReebGraph ( ReebGraph rg,
int  level 
) [static]
static float cotan_weight ( float *  v1,
float *  v2,
float *  v3 
) [static]

Definition at line 2681 of file reeb.c.

References cross_v3_v3v3(), dot_v3v3(), len_v3(), and sub_v3_v3v3().

Referenced by addTriangle().

static int countArcBuckets ( ReebArc arc) [static]

Definition at line 697 of file reeb.c.

References ReebArc::head, ReebArc::tail, and ReebNode::weight.

Referenced by allocArcBuckets(), and resizeArcBuckets().

static ReebEdge* createArc ( ReebGraph rg,
ReebNode node1,
ReebNode node2 
) [static]
static int edgeEquals ( ReebEdge e1,
ReebEdge e2 
) [static]

Definition at line 2156 of file reeb.c.

References ReebEdge::v1, and ReebEdge::v2.

Referenced by nextArcMappedToEdge().

static void exportNode ( FILE *  f,
const char *  text,
ReebNode node 
) [static]

Definition at line 2025 of file reeb.c.

References ReebNode::degree, ReebNode::index, ReebNode::p, and ReebNode::weight.

Referenced by REEB_exportGraph().

static void ExtendArcBuckets ( ReebArc arc) [static]
static void extendGraphBuckets ( ReebGraph rg) [static]

Definition at line 910 of file reeb.c.

References ReebGraph::arcs, ExtendArcBuckets(), ListBase::first, and ReebArc::next.

Referenced by finalizeGraph().

static void fillArcEmptyBuckets ( ReebArc arc) [static]
static void filterArc ( ReebGraph rg,
ReebNode newNode,
ReebNode removedNode,
ReebArc srcArc,
int  merging 
) [static]
static int filterCyclesReebGraph ( ReebGraph rg,
float   UNUSEDdistance_threshold 
) [static]
static void filterGraph ( ReebGraph rg,
short  options,
float  threshold_internal,
float  threshold_external 
) [static]
static int filterInternalExternalReebGraph ( ReebGraph rg,
float  threshold_internal,
float  threshold_external 
) [static]
void filterNullReebGraph ( ReebGraph rg)
int filterSmartReebGraph ( ReebGraph UNUSEDrg,
float   UNUSEDthreshold 
)
static void finalizeGraph ( ReebGraph rg,
char  passes,
char  method 
) [static]
static void fixSubgraphsOrientation ( ReebGraph rg,
int  nb_subgraphs 
) [static]
static void flipArc ( ReebArc arc) [static]

Definition at line 436 of file reeb.c.

References flipArcBuckets(), ReebArc::head, and ReebArc::tail.

Referenced by filterArc(), and reweightArc().

void flipArcBuckets ( ReebArc arc)

Definition at line 683 of file reeb.c.

References ReebArc::bcount, ReebArc::buckets, and i.

Referenced by flipArc().

static void freeEdgeIndex ( EdgeIndex indexed_edges) [static]

Definition at line 2957 of file reeb.c.

References EdgeIndex::edges, MEM_freeN(), and EdgeIndex::offset.

Referenced by BIF_ReebGraphMultiFromEditMesh().

ReebGraph* generateReebGraph ( EditMesh em,
int  subdivisions 
)
static void glueByMergeSort ( ReebGraph rg,
ReebArc a0,
ReebArc a1,
ReebEdge e0,
ReebEdge e1 
) [static]

Definition at line 2390 of file reeb.c.

References mergeArcs(), nextArcMappedToEdge(), NULL, ReebArc::tail, and ReebNode::weight.

Referenced by mergePaths().

static void * headNode ( void *  arg) [static]
static int indexData ( EditVert eve) [static]

Definition at line 137 of file reeb.c.

References EditVert::p, and EditVert::tmp.

Referenced by addTriangle(), buildIndexedEdges(), and shortestPathsFromVert().

void initArcIterator ( BArcIterator arg,
ReebArc arc,
ReebNode head 
)
void initArcIterator2 ( BArcIterator arg,
ReebArc arc,
int  start,
int  end 
)
void initArcIteratorStart ( BArcIterator arg,
struct ReebArc arc,
struct ReebNode head,
int  start 
)
static void initIteratorFct ( ReebArcIterator iter) [static]
static void interpolateBuckets ( ReebArc arc,
float *  start_p,
float *  end_p,
int  start_index,
int  end_index 
) [static]
static int iteratorStopped ( void *  arg) [static]

Definition at line 3362 of file reeb.c.

References ReebArcIterator::index, and ReebArcIterator::length.

Referenced by initIteratorFct().

static int joinSubgraphs ( ReebGraph rg,
float  threshold 
) [static]
static int joinSubgraphsEnds ( ReebGraph rg,
float  threshold,
int  nb_subgraphs 
) [static]
static float lengthArc ( ReebArc arc) [static]

Definition at line 1463 of file reeb.c.

References ReebArc::head, ReebArc::length, ReebArc::tail, and ReebNode::weight.

Referenced by compareArcs(), and filterInternalExternalReebGraph().

static void mergeArcBuckets ( ReebArc aDst,
ReebArc aSrc,
float  start,
float  end 
) [static]
void mergeArcEdges ( ReebGraph rg,
ReebArc aDst,
ReebArc aSrc,
MergeDirection  direction 
)
void mergeArcFaces ( ReebGraph rg,
ReebArc aDst,
ReebArc aSrc 
)
void mergeArcFaces ( ReebGraph UNUSEDrg,
ReebArc aDst,
ReebArc aSrc 
)
int mergeArcs ( ReebGraph rg,
ReebArc a0,
ReebArc a1 
)
static void mergeBuckets ( EmbedBucket bDst,
EmbedBucket bSrc 
) [static]

Definition at line 639 of file reeb.c.

References interp_v3_v3v3(), EmbedBucket::nv, EmbedBucket::p, and VECCOPY.

Referenced by mergeArcBuckets().

int mergeConnectedArcs ( ReebGraph rg,
ReebArc a0,
ReebArc a1 
)
static void mergePaths ( ReebGraph rg,
ReebEdge e0,
ReebEdge e1,
ReebEdge e2 
) [static]

Definition at line 2411 of file reeb.c.

References ReebEdge::arc, and glueByMergeSort().

Referenced by addTriangleToGraph().

ReebGraph* newReebGraph ( void  )
static ReebArc* nextArcMappedToEdge ( ReebArc arc,
ReebEdge e 
) [static]
static void * nextBucket ( void *  arg) [static]
EditEdge * NextEdgeForVert ( EdgeIndex indexed_edges,
int  index 
)

Definition at line 2868 of file reeb.c.

References EdgeIndex::edges, NULL, and EdgeIndex::offset.

Referenced by shortestPathsFromVert(), and weightToHarmonic().

static void * nextNBucket ( void *  arg,
int  n 
) [static]
static ReebNode* nodeData ( EditVert eve) [static]

Definition at line 152 of file reeb.c.

References EditVert::p, and EditVert::tmp.

Referenced by generateReebGraph().

static void NodeDegreeDecrement ( ReebGraph UNUSEDrg,
ReebNode node 
) [static]
static void NodeDegreeIncrement ( ReebGraph UNUSEDrg,
ReebNode node 
) [static]

Definition at line 457 of file reeb.c.

References ReebNode::degree.

Referenced by createArc(), filterArc(), joinSubgraphsEnds(), and mergeArcs().

static void nodeSetData ( EditVert eve,
ReebNode n 
) [static]

Definition at line 157 of file reeb.c.

References EditVert::p, and EditVert::tmp.

Referenced by addNode().

static void * peekBucket ( void *  arg,
int  n 
) [static]
void postprocessGraph ( ReebGraph rg,
char  mode 
)
static void * previousBucket ( void *  arg) [static]
static void printArc ( ReebArc arc) [static]
void REEB_AxialSymmetry ( BNode root_node,
BNode node1,
BNode node2,
struct BArc barc1,
BArc barc2 
)
void REEB_exportGraph ( ReebGraph rg,
int  count 
)
void REEB_freeArc ( BArc barc)
void REEB_freeGraph ( ReebGraph rg)
void REEB_RadialSymmetry ( BNode root_node,
RadialArc ring,
int  count 
)
static void relinkNodes ( ReebGraph low_rg,
ReebGraph high_rg 
) [static]
void removeNormalNodes ( ReebGraph rg)
static void removeZeroNodes ( ReebGraph rg) [static]

Definition at line 2070 of file reeb.c.

References BLI_removeNode(), ReebNode::degree, ListBase::first, ReebNode::next, and ReebGraph::nodes.

Referenced by generateReebGraph().

void renormalizeWeight ( EditMesh em,
float  newmax 
)
void repositionNodes ( ReebGraph rg)
static void resizeArcBuckets ( ReebArc arc) [static]
static void reweightArc ( ReebGraph rg,
ReebArc arc,
ReebNode start_node,
float  start_weight 
) [static]
static void reweightBuckets ( ReebArc arc) [static]

Definition at line 766 of file reeb.c.

References ReebArc::bcount, ReebArc::buckets, ReebArc::head, i, and EmbedBucket::val.

Referenced by reweightArc().

static void reweightSubgraph ( ReebGraph rg,
ReebNode start_node,
float  start_weight 
) [static]
static void setIteratorValues ( ReebArcIterator iter,
EmbedBucket bucket 
) [static]
static void shortestPathsFromVert ( EditMesh em,
EditVert starting_vert,
EdgeIndex indexed_edges 
) [static]
void sortArcs ( ReebGraph rg)

Definition at line 1247 of file reeb.c.

References ReebGraph::arcs, BLI_sortlist(), and compareArcsWeight().

Referenced by finalizeGraph().

void sortNodes ( ReebGraph rg)

Definition at line 1221 of file reeb.c.

References BLI_sortlist(), compareNodesWeight(), and ReebGraph::nodes.

Referenced by finalizeGraph(), and joinSubgraphs().

static void spreadWeight ( EditMesh em) [static]
static void * tailNode ( void *  arg) [static]
void verifyArcs ( ReebGraph rg)
void verifyBuckets ( ReebGraph rg)

Definition at line 558 of file reeb.c.

References ReebGraph::arcs, ListBase::first, ReebArc::next, NULL, and verifyBucketsArc().

static void verifyBucketsArc ( ReebGraph UNUSEDrg,
ReebArc arc 
) [static]
void verifyFaces ( ReebGraph rg)

Definition at line 569 of file reeb.c.

References ReebGraph::arcs, BLI_ghash_size(), ReebArc::faces, ListBase::first, ReebArc::next, and NULL.

static void verifyMultiResolutionLinks ( ReebGraph rg,
int  level 
) [static]
void verifyNodeDegree ( ReebGraph rg)
static float weightData ( EditVert eve) [static]
int weightFromDistance ( EditMesh em,
EdgeIndex indexed_edges 
)
int weightFromLoc ( EditMesh em,
int  axis 
)
static void weightSetData ( EditVert eve,
float  w 
) [static]
int weightToHarmonic ( EditMesh em,
EdgeIndex indexed_edges 
)