[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38031] branches/soc-2011-avocado/blender: Filtering our eigenvectors whose corresponding eigenvalue is near to zero and changes in the threshold value for adjacency in graph_is_connected function .

shuvro sarker shuvro05 at gmail.com
Sat Jul 2 08:37:02 CEST 2011


Revision: 38031
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38031
Author:   shuvro
Date:     2011-07-02 06:37:02 +0000 (Sat, 02 Jul 2011)
Log Message:
-----------
Filtering our eigenvectors whose corresponding eigenvalue is near to zero and changes in the threshold value for adjacency in graph_is_connected function.

Modified Paths:
--------------
    branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.cpp
    branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.h
    branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.cpp
    branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.cpp
    branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.h
    branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.cpp
    branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.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-07-02 05:05:03 UTC (rev 38030)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.cpp	2011-07-02 06:37:02 UTC (rev 38031)
@@ -1,11 +1,12 @@
 #include "AutoseamAdjacency.h"
 #include <stdio.h>
 
-#define THRESHOLD_ZERO 0.05
+#define THRESHOLD_ZERO 0.0005
 AutoseamAdjacency::AutoseamAdjacency(int dimension)
 {    
     m_adjacency = MatrixXd::Zero(dimension, dimension);
     m_index_map_vector.resize(dimension, -1);
+    //threshold_value = min_value;
 }
 
 void AutoseamAdjacency::set(int row, int col, float value)
@@ -15,6 +16,10 @@
    
 }
 
+void AutoseamAdjacency::set_min_value(float min_value)
+{
+    threshold_value = min_value;
+}
 
 int AutoseamAdjacency::get(int row, int col)
 {
@@ -99,15 +104,16 @@
         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)
-            //if(evalues[n-f-1] >= 0.0 && evalues[n-f-1] < 0.0005){
+            if(fabs(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);
             
+//                printf("four values are: %d %d %d %d", aplus.rows(), aplus.cols(), aminus.rows(), aminus.cols());
                 // We filter out eigenspaces that give non-connected F+ and F- as in the paper
-                if (is_graph_connected(aplus) && is_graph_connected(aminus)) {
+                if ((is_graph_connected(aplus, threshold_value) && is_graph_connected(aminus, threshold_value))) {
                     m_eigenspaces.push_back(aes);
                     found = true;
                 } 
@@ -115,8 +121,7 @@
                     delete aes;
                 }
             
-                
-            //}
+            }
             f++;
         }
         return found;

Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.h	2011-07-02 05:05:03 UTC (rev 38030)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.h	2011-07-02 06:37:02 UTC (rev 38031)
@@ -13,7 +13,8 @@
     public:
         AutoseamAdjacency(int dimension);
         ~AutoseamAdjacency();
-
+        
+        void set_min_value(float min_value);
         void set(int row, int col, float value);
         int get(int row, int col);
         const Eigen::MatrixXd& getMatrix() const { return m_adjacency; }
@@ -32,6 +33,7 @@
         Eigen::MatrixXd m_adjacency;
         std::vector<AutoseamEigenspace*> m_eigenspaces;
         std::vector<int> m_index_map_vector;
+        float threshold_value;
         //map<int,int> m_index_map;
 	
 };

Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.cpp	2011-07-02 05:05:03 UTC (rev 38030)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.cpp	2011-07-02 06:37:02 UTC (rev 38031)
@@ -1,7 +1,7 @@
 #include "AutoseamEigenspace.h"
 
+#define THRESHOLD_ZERO 0.0001
 
-
 AutoseamEigenspace::AutoseamEigenspace(double eigenval, const Eigen::VectorXd& eigenvector)
 : e(eigenval), v(eigenvector)
 {
@@ -72,9 +72,10 @@
     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 ) {
+            if (adj( m_fplus[m], m_fminus[n] ) > THRESHOLD_ZERO ) {
                 /*an experimental change to see if this improves our result*/
-                count += adj(m_fplus[m], m_fminus[n]);
+                //count += adj(m_fplus[m], m_fminus[n]);
+                count += 1;
                 break;
             }
         }

Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.cpp	2011-07-02 05:05:03 UTC (rev 38030)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.cpp	2011-07-02 06:37:02 UTC (rev 38031)
@@ -27,29 +27,30 @@
  */
 #include "AutoseamUtility.h"
 
-void depth_first_search(const MatrixXd& adjacency, int u, GraphNodeColor state[]) 
+void depth_first_search(const MatrixXd& adjacency, int u, GraphNodeColor state[], float min_value) 
 {
     int nNodes = adjacency.cols();
     state[u] = Gray;
     for (int v = 0; v < nNodes; v++) {
         if (u != v) {
             double adj = adjacency(u, v);
-            if ((adj>0.005) && state[v] == White) {
-                depth_first_search(adjacency, v, state);
+            //printf("min value: %lf",min_value);
+            if ((adj >= min_value) && state[v] == White) {
+                depth_first_search(adjacency, v, state, min_value);
             }
         }
     }
     state[u] = Black;
 }
 
-bool is_graph_connected(const MatrixXd& adjacency) 
+bool is_graph_connected(const MatrixXd& adjacency, float min_value) 
 {
     int nNodes = adjacency.cols();
     if (nNodes > 0) {
         GraphNodeColor *state = new GraphNodeColor[nNodes];
         for (int i = 0; i < nNodes; i++)
             state[i] = White;
-        depth_first_search(adjacency, 0, state);
+        depth_first_search(adjacency, 0, state, min_value);
         bool connected = true;
         for (int i = 0; i < nNodes; i++) {
             if ( state[i] != Black ) {

Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.h	2011-07-02 05:05:03 UTC (rev 38030)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.h	2011-07-02 06:37:02 UTC (rev 38031)
@@ -37,8 +37,8 @@
 using Eigen::MatrixXd;
 
 enum GraphNodeColor { White, Gray, Black };
-bool is_graph_connected(const MatrixXd& adjacency);
-void depth_first_search(const MatrixXd& adjacency, int u, GraphNodeColor state[]);
+bool is_graph_connected(const MatrixXd& adjacency, float min_value);
+void depth_first_search(const MatrixXd& adjacency, int u, GraphNodeColor state[], float min_value);
 
 
 class AutoseamUtility

Modified: branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.cpp	2011-07-02 05:05:03 UTC (rev 38030)
+++ branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.cpp	2011-07-02 06:37:02 UTC (rev 38031)
@@ -55,6 +55,12 @@
     return (AUTOSEAM_Adjacency) adj;
 }
 
+void autoseam_set_min_value(AUTOSEAM_Adjacency handle, float min_value)
+{
+    AutoseamAdjacency *adj = reinterpret_cast<AutoseamAdjacency*>(handle);
+    adj->set_min_value(min_value);
+}
+
 void autoseam_delete_adjacency(AUTOSEAM_Adjacency handle)
 {
     AutoseamAdjacency *adj = reinterpret_cast<AutoseamAdjacency*>(handle);

Modified: branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.h	2011-07-02 05:05:03 UTC (rev 38030)
+++ branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.h	2011-07-02 06:37:02 UTC (rev 38031)
@@ -47,6 +47,7 @@
 /* Laplacian Matrix */
 AUTOSEAM_Adjacency autoseam_create_adjacency(int dimension);
 void autoseam_delete_adjacency(AUTOSEAM_Adjacency handle);
+void autoseam_set_min_value(AUTOSEAM_Adjacency handle, float min_value);
 void autoseam_set_adjacent(AUTOSEAM_Adjacency handle, int row, int col, float value);
 int autoseam_is_adjacent(AUTOSEAM_Adjacency handle, int row, int col);
 

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-07-02 05:05:03 UTC (rev 38030)
+++ branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c	2011-07-02 06:37:02 UTC (rev 38031)
@@ -57,7 +57,9 @@
 #include "MEM_guardedalloc.h"
 #include "WM_api.h"
 
+#define INF 999999
 
+static float min_value = INF;
 
 int get_sign(float number){
     return number > 0.0 ? 1 : 2;
@@ -157,7 +159,7 @@
    
     float edge_length;
     float poly_centres[2][3];
-    int k;
+    //int k;
     
     for(edge = BMIter_New(&edge_iter, bm, BM_EDGES_OF_MESH, bm ); edge; edge= BMIter_Step(&edge_iter)) 
     {
@@ -171,6 +173,7 @@
                 
                 if(!combinatorial){
                     autoseam_set_adjacent(adj, loop->f->head.index, loop->radial_next->f->head.index, 1.0);
+                    min_value = 1.0;
                 }
                 else{
                     float dx, dy, dz;
@@ -188,8 +191,9 @@
                         if(is_first_index == 1){
                             int is_second_index = is_element_in_array(loop->radial_next->f->head.index, faces, num_faces);
                             if(is_second_index == 1){
-                                //printf("edge :%d %d", loop->f->head.index, loop->radial_next->f->head.index);
                                 autoseam_set_adjacent(adj, loop->f->head.index, loop->radial_next->f->head.index, edge_length);
+                                
+                                if(edge_length < min_value) min_value = edge_length;
 
                             }
                         }
@@ -197,6 +201,7 @@
                     }
                     else{
                         autoseam_set_adjacent(adj, loop->f->head.index, loop->radial_next->f->head.index, edge_length);
+                        if(edge_length < min_value) min_value = edge_length;
                     }
                 }
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list