[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37465] branches/soc-2011-avocado/blender: Initial seam generation based on only one eigen vector.

shuvro sarker shuvro05 at gmail.com
Tue Jun 14 05:47:08 CEST 2011


Revision: 37465
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37465
Author:   shuvro
Date:     2011-06-14 03:47:08 +0000 (Tue, 14 Jun 2011)
Log Message:
-----------
Initial seam generation based on only one eigen vector.

Modified Paths:
--------------
    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
    branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.h

Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.cpp	2011-06-14 03:36:53 UTC (rev 37464)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.cpp	2011-06-14 03:47:08 UTC (rev 37465)
@@ -58,7 +58,7 @@
 
 
 
-void AutoseamUtility::calculate_eigen(float **dual_matrix, int num_row, int num_col)
+void AutoseamUtility::calculate_eigen(float **dual_matrix, int num_row, int num_col, float **eigen_vectors, float *eigen_values)
 {
     int i,l,r_index,c_index;
     dualMatrix.resize(num_row, num_col);
@@ -89,8 +89,19 @@
     
     for(i = 0; i < num_col; i++ )
     {
-        std::cout << "Column "  << i << ": value " << es.eigenvalues()[i] << std::endl;
+        int num_vectors = es.eigenvectors().cols();
+        int loop;
+        
+        eigen_values[i] = es.eigenvalues()[i].real();
+        //std::cout << "Column "  << i << ": value " << es.eigenvalues()[i] << std::endl;
         std::cout << "Column "  << i << ": vector " << es.eigenvectors().col(i) << std::endl;
+        
+        for(loop = 0; loop < num_vectors; loop++){
+            eigen_vectors[i][loop] = es.eigenvectors().col(i)[loop].real();
+            std::cout << "vector value: " << es.eigenvectors().col(i)[loop].real() << std::endl;
+            
+        }
+        
     }
 
     

Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.h	2011-06-14 03:36:53 UTC (rev 37464)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.h	2011-06-14 03:47:08 UTC (rev 37465)
@@ -36,7 +36,7 @@
 	public:
         AutoseamUtility();
 
-        void calculate_eigen(float **dual_matrix, int num_row, int num_col);
+        void calculate_eigen(float **dual_matrix, int num_row, int num_col, float **eigen_vectors, float *eigen_values);
 
 		Eigen::Matrix3f m_A;
 		Eigen::Vector3f m_x;

Modified: branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.cpp	2011-06-14 03:36:53 UTC (rev 37464)
+++ branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.cpp	2011-06-14 03:47:08 UTC (rev 37465)
@@ -41,8 +41,8 @@
 	delete utility;
 }
 
-void autoseam_calculate_eigen(AUTOSEAM_UtilityClassHandle handle, float** vec, int dimension)
+void autoseam_calculate_eigen(AUTOSEAM_UtilityClassHandle handle, float** vec, int dimension, float **eigen_vectors, float *eigen_values)
 {
 	AutoseamUtility *utility = reinterpret_cast<AutoseamUtility*>(handle);
-	utility->calculate_eigen(vec, dimension, dimension);
+	utility->calculate_eigen(vec, dimension, dimension, eigen_vectors, eigen_values);
 }
\ No newline at end of file

Modified: branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.h	2011-06-14 03:36:53 UTC (rev 37464)
+++ branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.h	2011-06-14 03:47:08 UTC (rev 37465)
@@ -41,7 +41,7 @@
 AUTOSEAM_UtilityClassHandle autoseam_create_utility();
 void autoseam_delete_utility(AUTOSEAM_UtilityClassHandle handle);
 
-void autoseam_calculate_eigen(AUTOSEAM_UtilityClassHandle handle, float** vec, int dimension);
+void autoseam_calculate_eigen(AUTOSEAM_UtilityClassHandle handle, float** vec, int dimension, float **eigen_vectors, float *eigen_values);
 
 #ifdef __cplusplus
 }

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-14 03:36:53 UTC (rev 37464)
+++ branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c	2011-06-14 03:47:08 UTC (rev 37465)
@@ -59,12 +59,15 @@
 
 #define MAX_LOOPS_OF_EDGE 1000
 
-
+int get_sign(float number){
+    return number > 0.0 ? 1 : 2;
+}
 static int compute_dual_graph(BMesh *bm, int combinatorial)
 {
     BMEdge *eed;
     BMIter iter, iter2;
     BMLoop *l;
+    BMFace *face_left, *face_right;
     
     int i,k,m,face_index[MAX_LOOPS_OF_EDGE];
     float poly_centres[MAX_LOOPS_OF_EDGE][3];
@@ -72,6 +75,9 @@
     
     float **dummy_dual_graph;
     int num_faces;
+    float **eigen_vectors;
+    float *eigen_values;
+    
     //float face_center[3], face_center_second[3];
     
     num_faces = BM_Count_Element(bm, BM_FACE);
@@ -79,15 +85,20 @@
     
     /* allocate memory for a num_faces x num_faces matrix */
     dummy_dual_graph = (float **)MEM_callocN(sizeof(float*)*num_faces, "dual_graph");
+    eigen_vectors    = (float **)MEM_callocN(sizeof(float*)*num_faces, "eigen_vectors");
     
+    eigen_values     = (float *)MEM_callocN(sizeof(float)*num_faces, "eigen_values");
+    
     for(k = 0; k < num_faces; k++ ){
         dummy_dual_graph[k] = (float *)MEM_callocN(sizeof(float)*num_faces, "dual_row");
+        eigen_vectors[k]    = (float *)MEM_callocN(sizeof(float)*num_faces, "eigen_vec"); 
     }    
     
     /* set the initial values for the allocated matrix. */
     for(k = 0; k < num_faces; k++){
         for(m = 0; m < num_faces; m++){
             dummy_dual_graph[k][m] = 0.0f;
+            eigen_vectors[k][m]    = 0.0f;
         }
     }
     
@@ -102,8 +113,9 @@
             i = 0;
             
             BM_ITER(l, &iter2, bm, BM_LOOPS_OF_EDGE, eed) {
-                face_index[i++] = l->f->head.index;
+                face_index[i] = l->f->head.index;
                 BM_Compute_Face_Center(bm, l->f, poly_centres[i]);
+                i++;
             }
             
             for(m = 0; m < i ; m++){
@@ -134,13 +146,64 @@
         }
     }
     
-    calculate_eigen(dummy_dual_graph, num_faces);
+    calculate_eigen(dummy_dual_graph, num_faces, eigen_vectors, eigen_values);
     
+    /*for(k = 0; k < num_faces; k++){
+        for(m = 0; m < num_faces; m++){
+            printf("%f ", eigen_vectors[k][m]);
+        }
+        printf("\n");
+    }*/
+    
+    for(eed = BMIter_New(&iter, bm, BM_EDGES_OF_MESH, bm ); eed; eed= BMIter_Step(&iter)) {
+        
+        if(!BM_Boundary_Edge(eed)){
+            int flag;
+            int sign;
+            
+            i = 0;
+            flag = 0;
+            
+            BM_ITER(l, &iter2, bm, BM_LOOPS_OF_EDGE, eed) {
+                if(!i){
+                    sign = get_sign(eigen_vectors[0][l->f->head.index]);
+                    face_left = l->f;
+                }
+                else if(sign != get_sign(l->f->head.index)) {
+                    flag = 1;
+                    face_right = l->f;
+                    break;
+                }
+                i++;
+            }
+            
+            if(flag){
+                BMVert *v1, *v2;
+                BMEdge *seam_edge;
+                float vert_co[3];
+                
+                BM_Compute_Face_Center(bm, face_left, vert_co);
+                v1 = BM_Make_Vert(bm, vert_co, NULL);
+                
+                BM_Compute_Face_Center(bm, face_right, vert_co);
+                v2 = BM_Make_Vert(bm, vert_co, NULL);
+                
+                seam_edge = BM_Make_Edge(bm, v1, v2, NULL, 0);
+                
+                BM_SetHFlag(seam_edge, BM_SEAM);
+            }
+        
+        }
+        //calculate length.
+    }
     for(k = 0; k < num_faces; k++ ){
         MEM_freeN(dummy_dual_graph[k]);
+        MEM_freeN(eigen_vectors[k]);
     }
     
     MEM_freeN(dummy_dual_graph);
+    MEM_freeN(eigen_vectors);
+    MEM_freeN(eigen_values);
     return 0;
 }
 
@@ -174,11 +237,11 @@
 }
 
 
-void calculate_eigen(float **dual_graph, int dimension)
+void calculate_eigen(float **dual_graph, int dimension, float **eigen_vectors, float *eigen_values)
 {
     AUTOSEAM_UtilityClassHandle handle = autoseam_create_utility();
     
-    autoseam_calculate_eigen(handle, dual_graph, dimension);
+    autoseam_calculate_eigen(handle, dual_graph, dimension, eigen_vectors, eigen_values);
 
 	autoseam_delete_utility(handle);
 }

Modified: branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.h
===================================================================
--- branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.h	2011-06-14 03:36:53 UTC (rev 37464)
+++ branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.h	2011-06-14 03:47:08 UTC (rev 37465)
@@ -29,9 +29,8 @@
 #ifndef AUTOSEAM_TOOLS_H
 #define AUTOSEAM_TOOLS_H
 
-/* XXXXX TODO_SHUVRO: is this needed? If not, remove */
+void calculate_eigen(float **dual_graph, int dimension, float **eigen_vectors, float *eigen_valuess);
+int get_sign(float number);
 
-void calculate_eigen(float **dual_graph, int dimension);
 
-
 #endif
\ No newline at end of file




More information about the Bf-blender-cvs mailing list