[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15337] branches/harmonic-skeleton/source/ blender: More robust primary symmetry axis algorithm (support branch in two )
Martin Poirier
theeth at yahoo.com
Mon Jun 23 23:47:46 CEST 2008
Revision: 15337
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15337
Author: theeth
Date: 2008-06-23 23:47:31 +0200 (Mon, 23 Jun 2008)
Log Message:
-----------
More robust primary symmetry axis algorithm (support branch in two)
Draw primary axis and weight delta
Modified Paths:
--------------
branches/harmonic-skeleton/source/blender/blenlib/intern/graph.c
branches/harmonic-skeleton/source/blender/makesdna/DNA_scene_types.h
branches/harmonic-skeleton/source/blender/src/buttons_editing.c
branches/harmonic-skeleton/source/blender/src/reeb.c
Modified: branches/harmonic-skeleton/source/blender/blenlib/intern/graph.c
===================================================================
--- branches/harmonic-skeleton/source/blender/blenlib/intern/graph.c 2008-06-23 20:46:36 UTC (rev 15336)
+++ branches/harmonic-skeleton/source/blender/blenlib/intern/graph.c 2008-06-23 21:47:31 UTC (rev 15337)
@@ -695,10 +695,15 @@
void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level, float limit)
{
int i;
- arc->symmetry_level = level;
+
+ /* if arc is null, we start straight from a node */
+ if (arc)
+ {
+ arc->symmetry_level = level;
+
+ node = BLI_otherNode(arc, node);
+ }
- node = BLI_otherNode(arc, node);
-
for (i = 0; i < node->degree; i++)
{
BArc *connectedArc = node->arcs[i];
@@ -727,7 +732,7 @@
/* true by default */
issymmetryAxis = 1;
- for (j = 0; j < node->degree && issymmetryAxis == 1; j++)
+ for (j = 0; j < node->degree; j++)
{
BArc *otherArc = node->arcs[j];
@@ -736,6 +741,7 @@
{
/* not on the symmetry axis */
issymmetryAxis = 0;
+ break;
}
}
}
@@ -748,11 +754,10 @@
{
arc = connectedArc;
}
- else
+ else if (connectedArc->symmetry_level < arc->symmetry_level)
{
- /* there can't be more than one symmetry arc */
- arc = NULL;
- break;
+ /* go with more complex subtree as symmetry arc */
+ arc = connectedArc;
}
}
}
@@ -796,13 +801,22 @@
node = root_node;
- /* only work on acyclic graphs and if only one arc is incident on the first node */
- if (node->degree == 1)
+ /* sanity check REMOVE ME */
+ if (node->degree > 0)
{
arc = node->arcs[0];
- markdownSymmetryArc(graph, arc, node, 1, limit);
+ if (node->degree == 1)
+ {
+ markdownSymmetryArc(graph, arc, node, 1, limit);
+ }
+ else
+ {
+ markdownSymmetryArc(graph, NULL, node, 1, limit);
+ }
+
+
/* mark down non-symetric arcs */
for (arc = graph->arcs.first; arc; arc = arc->next)
{
Modified: branches/harmonic-skeleton/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- branches/harmonic-skeleton/source/blender/makesdna/DNA_scene_types.h 2008-06-23 20:46:36 UTC (rev 15336)
+++ branches/harmonic-skeleton/source/blender/makesdna/DNA_scene_types.h 2008-06-23 21:47:31 UTC (rev 15337)
@@ -841,6 +841,7 @@
#define SKGEN_HARMONIC 64
#define SKGEN_STICK_TO_EMBEDDING 128
#define SKGEN_ADAPTIVE_DISTANCE 512
+#define SKGEN_FILTER_SMART 1024
#define SKGEN_SUB_LENGTH 0
#define SKGEN_SUB_ANGLE 1
Modified: branches/harmonic-skeleton/source/blender/src/buttons_editing.c
===================================================================
--- branches/harmonic-skeleton/source/blender/src/buttons_editing.c 2008-06-23 20:46:36 UTC (rev 15336)
+++ branches/harmonic-skeleton/source/blender/src/buttons_editing.c 2008-06-23 21:47:31 UTC (rev 15337)
@@ -5021,9 +5021,10 @@
uiDefButS(block, NUM, B_DIFF, "Resolution:", 1025,150,225,19, &G.scene->toolsettings->skgen_resolution,10.0,1000.0, 0, 0, "Specifies the resolution of the graph's embedding");
uiDefButBitS(block, TOG, SKGEN_HARMONIC, B_DIFF, "H", 1250,150, 25,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0, "Apply harmonic smoothing to the weighting");
uiDefButBitS(block, TOG, SKGEN_FILTER_INTERNAL, B_DIFF, "Filter In", 1025,130, 83,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0, "Filter internal small arcs from graph");
- uiDefButF(block, NUM, B_DIFF, "T:", 1111,130,164,19, &G.scene->toolsettings->skgen_threshold_internal,0.0, 1.0, 10, 0, "Specify the threshold ratio for filtering internal arcs");
- uiDefButBitS(block, TOG, SKGEN_FILTER_EXTERNAL, B_DIFF, "Filter Ex", 1025,110, 83,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0, "Filter external small arcs from graph");
- uiDefButF(block, NUM, B_DIFF, "T:", 1111,110,164,19, &G.scene->toolsettings->skgen_threshold_external,0.0, 1.0, 10, 0, "Specify the threshold ratio for filtering external arcs");
+ uiDefButF(block, NUM, B_DIFF, "", 1111,130,164,19, &G.scene->toolsettings->skgen_threshold_internal,0.0, 1.0, 10, 0, "Specify the threshold ratio for filtering internal arcs");
+ uiDefButBitS(block, TOG, SKGEN_FILTER_EXTERNAL, B_DIFF, "Filter Ex", 1025,110, 53,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0, "Filter external small arcs from graph");
+ uiDefButBitS(block, TOG, SKGEN_FILTER_SMART, B_DIFF, "Sm", 1078,110, 30,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0, "Smart Filtering");
+ uiDefButF(block, NUM, B_DIFF, "", 1111,110,164,19, &G.scene->toolsettings->skgen_threshold_external,0.0, 1.0, 10, 0, "Specify the threshold ratio for filtering external arcs");
uiBlockEndAlign(block);
uiDefButF(block, NUM, B_DIFF, "Ang:", 1025, 60, 83,19, &G.scene->toolsettings->skgen_retarget_angle_weight, 0, 10, 1, 0, "Angle Weight");
@@ -5057,13 +5058,16 @@
uiButSetFunc(but, skgen_graphfree, NULL, NULL);
uiBlockBeginAlign(block);
- uiDefButS(block, NUM, B_DIFF, "Resolution:", 1025,150,225,19, &G.scene->toolsettings->skgen_resolution,2.0,1000.0, 0, 0, "Specifies the resolution of the graph's embedding");
+ uiDefButS(block, NUM, B_DIFF, "Resolution:", 1025,150,225,19, &G.scene->toolsettings->skgen_resolution,10.0,1000.0, 0, 0, "Specifies the resolution of the graph's embedding");
uiDefButBitS(block, TOG, SKGEN_HARMONIC, B_DIFF, "H", 1250,150, 25,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0, "Apply harmonic smoothing to the weighting");
uiDefButBitS(block, TOG, SKGEN_FILTER_INTERNAL, B_DIFF, "Filter In", 1025,130, 83,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0, "Filter internal small arcs from graph");
- uiDefButF(block, NUM, B_DIFF, "T:", 1111,130,164,19, &G.scene->toolsettings->skgen_threshold_internal,0.0, 1.0, 10, 0, "Specify the threshold ratio for filtering internal arcs");
- uiDefButBitS(block, TOG, SKGEN_FILTER_EXTERNAL, B_DIFF, "Filter Ex", 1025,110, 83,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0, "Filter external small arcs from graph");
- uiDefButF(block, NUM, B_DIFF, "T:", 1111,110,164,19, &G.scene->toolsettings->skgen_threshold_external,0.0, 1.0, 10, 0, "Specify the threshold ratio for filtering external arcs");
+ uiDefButF(block, NUM, B_DIFF, "", 1111,130,164,19, &G.scene->toolsettings->skgen_threshold_internal,0.0, 1.0, 10, 0, "Specify the threshold ratio for filtering internal arcs");
+ uiDefButBitS(block, TOG, SKGEN_FILTER_EXTERNAL, B_DIFF, "Filter Ex", 1025,110, 53,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0, "Filter external small arcs from graph");
+ uiDefButBitS(block, TOG, SKGEN_FILTER_SMART, B_DIFF, "Sm", 1078,110, 30,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0, "Smart Filtering");
+ uiDefButF(block, NUM, B_DIFF, "", 1111,110,164,19, &G.scene->toolsettings->skgen_threshold_external,0.0, 1.0, 10, 0, "Specify the threshold ratio for filtering external arcs");
+ uiBlockEndAlign(block);
+ uiBlockBeginAlign(block);
for(i = 0; i < SKGEN_SUB_TOTAL; i++)
{
int y = 90 - 20 * i;
Modified: branches/harmonic-skeleton/source/blender/src/reeb.c
===================================================================
--- branches/harmonic-skeleton/source/blender/src/reeb.c 2008-06-23 20:46:36 UTC (rev 15336)
+++ branches/harmonic-skeleton/source/blender/src/reeb.c 2008-06-23 21:47:31 UTC (rev 15337)
@@ -46,6 +46,8 @@
#include "BDR_editobject.h"
+#include "BMF_Api.h"
+
#include "BIF_editmesh.h"
#include "BIF_editarmature.h"
#include "BIF_interface.h"
@@ -90,10 +92,10 @@
MERGE_APPEND
} MergeDirection;
-int mergeArcs(ReebGraph *GLOBAL_RG, ReebArc *a0, ReebArc *a1);
-int mergeConnectedArcs(ReebGraph *GLOBAL_RG, ReebArc *a0, ReebArc *a1);
+int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1);
+int mergeConnectedArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1);
EditEdge * NextEdgeForVert(EditMesh *em, EditVert *v);
-void mergeArcFaces(ReebGraph *GLOBAL_RG, ReebArc *aDst, ReebArc *aSrc);
+void mergeArcFaces(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc);
void addFacetoArc(ReebArc *arc, EditFace *efa);
void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count);
@@ -247,11 +249,11 @@
arc->length += VecLenf(arc->tail->p, vec1);
}
-void calculateGraphLength(ReebGraph *GLOBAL_RG)
+void calculateGraphLength(ReebGraph *rg)
{
ReebArc *arc;
- for (arc = GLOBAL_RG->arcs.first; arc; arc = arc->next)
+ for (arc = rg->arcs.first; arc; arc = arc->next)
{
calculateArcLength(arc);
}
@@ -298,13 +300,13 @@
MEM_freeN(arc);
}
-void REEB_freeGraph(ReebGraph *GLOBAL_RG)
+void REEB_freeGraph(ReebGraph *rg)
{
ReebArc *arc;
ReebNode *node;
// free nodes
- for( node = GLOBAL_RG->nodes.first; node; node = node->next )
+ for( node = rg->nodes.first; node; node = node->next )
{
// Free adjacency lists
if (node->arcs != NULL)
@@ -312,10 +314,10 @@
MEM_freeN(node->arcs);
}
}
- BLI_freelistN(&GLOBAL_RG->nodes);
+ BLI_freelistN(&rg->nodes);
// free arcs
- arc = GLOBAL_RG->arcs.first;
+ arc = rg->arcs.first;
while( arc )
{
ReebArc *next = arc->next;
@@ -324,23 +326,43 @@
}
// free edge map
- BLI_edgehash_free(GLOBAL_RG->emap, NULL);
+ BLI_edgehash_free(rg->emap, NULL);
- MEM_freeN(GLOBAL_RG);
+ MEM_freeN(rg);
}
-void repositionNodes(ReebGraph *GLOBAL_RG)
+void NodeDegreeDecrement(ReebGraph *rg, ReebNode *node)
{
+ node->degree--;
+
+// if (node->degree == 0)
+// {
+// printf("would remove node %i\n", node->index);
+// }
+}
+
+void NodeDegreeIncrement(ReebGraph *rg, ReebNode *node)
+{
+// if (node->degree == 0)
+// {
+// printf("first connect node %i\n", node->index);
+// }
+
+ node->degree++;
+}
+
+void repositionNodes(ReebGraph *rg)
+{
BArc *arc = NULL;
BNode *node = NULL;
// Reset node positions
- for(node = GLOBAL_RG->nodes.first; node; node = node->next)
+ for(node = rg->nodes.first; node; node = node->next)
{
node->p[0] = node->p[1] = node->p[2] = 0;
}
- for(arc = GLOBAL_RG->arcs.first; arc; arc = arc->next)
+ for(arc = rg->arcs.first; arc; arc = arc->next)
{
if (((ReebArc*)arc)->bcount > 0)
{
@@ -357,16 +379,16 @@
}
}
-void verifyNodeDegree(ReebGraph *GLOBAL_RG)
+void verifyNodeDegree(ReebGraph *rg)
{
-#ifdef DEBUG_REEB
+//#ifdef DEBUG_REEB
ReebNode *node = NULL;
ReebArc *arc = NULL;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list