[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37956] branches/soc-2011-avocado/blender: Added 'combinatorial' as parameter for the seam generation operator and improved edge selection by correcting seam length calculation

shuvro sarker shuvro05 at gmail.com
Wed Jun 29 20:17:49 CEST 2011


Revision: 37956
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37956
Author:   shuvro
Date:     2011-06-29 18:17:49 +0000 (Wed, 29 Jun 2011)
Log Message:
-----------
Added 'combinatorial' as parameter for the seam generation operator and improved edge selection by correcting seam length calculation

Modified Paths:
--------------
    branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.cpp
    branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.cpp
    branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.h
    branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c

Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.cpp	2011-06-29 18:17:11 UTC (rev 37955)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.cpp	2011-06-29 18:17:49 UTC (rev 37956)
@@ -1,6 +1,7 @@
 #include "AutoseamAdjacency.h"
 #include <stdio.h>
 
+#define THRESHOLD_ZERO 0.05
 AutoseamAdjacency::AutoseamAdjacency(int dimension)
 {    
     m_adjacency = MatrixXd::Zero(dimension, dimension);
@@ -17,7 +18,7 @@
 
 int AutoseamAdjacency::get(int row, int col)
 {
-    return m_adjacency(row, col) > 0.05 ? 1 : 0;
+    return m_adjacency(row, col) >  THRESHOLD_ZERO ? 1 : 0;
 }
 
 void AutoseamAdjacency::set_map_default()
@@ -98,20 +99,24 @@
         while ( (f < n)) {
             // Eigenvalues seem to be sorted largest to smallest, we need the 30 smallest
             // in the future only those will be calculated by the algorithm (if we use ARPACK)
-            AutoseamEigenspace* aes = new AutoseamEigenspace(evalues[n-f-1], es.eigenvectors().col(n-f-1));
-
-            // split Eigenspace into two subspaces F+ and F- where the ith entry in the eigenvector is positive/negative
-            aes->split();
-
-            aes->fill_adjacency(a, aplus, aminus);
-            // We filter out eigenspaces that give non-connected F+ and F- as in the paper
-            if (is_graph_connected(aplus) && is_graph_connected(aminus)) {
-                m_eigenspaces.push_back(aes);
-                found = true;
-            } 
-            else {
-            delete aes;
-            }
+            //if(evalues[n-f-1] >= 0.0 && evalues[n-f-1] < 0.0005){
+                
+                AutoseamEigenspace* aes = new AutoseamEigenspace(evalues[n-f-1], es.eigenvectors().col(n-f-1));
+                // split Eigenspace into two subspaces F+ and F- where the ith entry in the eigenvector is positive/negative
+                aes->split();
+                aes->fill_adjacency(a, aplus, aminus);
+            
+                // We filter out eigenspaces that give non-connected F+ and F- as in the paper
+                if (is_graph_connected(aplus) && is_graph_connected(aminus)) {
+                    m_eigenspaces.push_back(aes);
+                    found = true;
+                } 
+                else {
+                    delete aes;
+                }
+            
+                
+            //}
             f++;
         }
         return found;
@@ -165,12 +170,12 @@
 // get the longest seam with connected subgraphs F+ and F-
 int AutoseamAdjacency::get_best_split()
 {
-    int max_length= 0;
+    float max_length= 0;
     int best= 0;
     
     for (int i=0; i < m_eigenspaces.size(); ++i) {
         AutoseamEigenspace* aes = m_eigenspaces[i];
-        int len = aes->get_seam_length(m_adjacency);
+        float len = aes->get_seam_length(m_adjacency);
         if (len>max_length) {
             max_length = len;
             best = i;

Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.cpp	2011-06-29 18:17:11 UTC (rev 37955)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.cpp	2011-06-29 18:17:49 UTC (rev 37956)
@@ -66,14 +66,15 @@
 }
 
 
-int AutoseamEigenspace::get_seam_length(const Eigen::MatrixXd& adj)
+float AutoseamEigenspace::get_seam_length(const Eigen::MatrixXd& adj)
 {
-    int count= 0;
+    float count= 0;
     for (int m = 0; m < m_fplus.size(); ++m) 
     {
         for (int n = 0; n < m_fminus.size(); ++n) {
             if (adj( m_fplus[m], m_fminus[n] ) > 0.05 ) {
-                count++;
+                /*an experimental change to see if this improves our result*/
+                count += adj(m_fplus[m], m_fminus[n]);
                 break;
             }
         }

Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.h	2011-06-29 18:17:11 UTC (rev 37955)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.h	2011-06-29 18:17:49 UTC (rev 37956)
@@ -12,7 +12,7 @@
         void split();
         void fill_adjacency(const Eigen::MatrixXd& adj, Eigen::MatrixXd& adj_plus, Eigen::MatrixXd& adj_minus);
         void get(int *fplus, unsigned int* nplus, int* fminus, unsigned int* nminus);
-        int get_seam_length(const Eigen::MatrixXd& adj);
+        float get_seam_length(const Eigen::MatrixXd& adj);
     
     private:
     	double e;

Modified: branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c
===================================================================
--- branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c	2011-06-29 18:17:11 UTC (rev 37955)
+++ branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c	2011-06-29 18:17:49 UTC (rev 37956)
@@ -302,6 +302,7 @@
     AUTOSEAM_Adjacency adj;
     AUTOSEAM_Adjacency adj_big;
 	int maxdepth= RNA_int_get(op->ptr, "depth");
+    int is_combinatorial = RNA_boolean_get(op->ptr, "is_combinatorial");
 
     int num_faces;
 	
@@ -315,8 +316,8 @@
     autoseam_prepare_graph(bm);
     
     /* this creates the adjacency matrix */
-    autoseam_create_graph(adj, bm, 1, -1, NULL, 1);
-    autoseam_create_graph(adj_big, bm, 1, -1, NULL, 1);
+    autoseam_create_graph(adj, bm, is_combinatorial, -1, NULL, 1);
+    autoseam_create_graph(adj_big, bm, is_combinatorial, -1, NULL, 1);
     
     /* clear if any seam already exists. */
     autoseam_clear_seam(bm);
@@ -349,6 +350,7 @@
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 	
 	RNA_def_int(ot->srna, "depth", 1, 0, 6, "Recursion Depth", "Max. recursion depth", 0, 6);
+    RNA_def_boolean(ot->srna, "is_combinatorial", 1, "Calculate Combinatorial", "Store combinatorial edge distance in dual graph.");
 
 }
 




More information about the Bf-blender-cvs mailing list