Revision: 37722
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37722
Author:   shuvro
Date:     2011-06-22 04:23:34 +0000 (Wed, 22 Jun 2011)
Log Message:
-----------
Some fixes and restructure.

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/intern/autoseam/AutoseamUtility.cpp
    branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.h
    branches/soc-2011-avocado/blender/intern/autoseam/CMakeLists.txt
    
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-22 01:04:01 UTC (rev 37721)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.cpp     
2011-06-22 04:23:34 UTC (rev 37722)
@@ -17,7 +17,7 @@
 
 int AutoseamAdjacency::get(int row, int col)
 {
-    return m_adjacency(row, col) > 0.9 ? 1 : 0;
+    return m_adjacency(row, col) > 0.05 ? 1 : 0;
 }
 
 AutoseamAdjacency::~AutoseamAdjacency()
@@ -52,10 +52,11 @@
     Eigen::VectorXd evalues(es.eigenvalues());
     int f = 0;
     bool found = false;
-    int seam_length=0;
+//    int seam_length=0;
     MatrixXd aplus;
     MatrixXd aminus;
-    while ( (f < n) && (f<30) ) {
+    //while ( (f < n) && (f<30) ) {
+    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));
@@ -95,6 +96,7 @@
 {
     int 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);

Modified: 
branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.cpp    
2011-06-22 01:04:01 UTC (rev 37721)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.cpp    
2011-06-22 04:23:34 UTC (rev 37722)
@@ -1,6 +1,7 @@
 #include "AutoseamEigenspace.h"
 
 
+
 AutoseamEigenspace::AutoseamEigenspace(double eigenval, const Eigen::VectorXd& 
eigenvector)
 : e(eigenval), v(eigenvector)
 {

Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.h      
2011-06-22 01:04:01 UTC (rev 37721)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.h      
2011-06-22 04:23:34 UTC (rev 37722)
@@ -3,6 +3,7 @@
 
 #include <vector>
 #include "AutoseamUtility.h"
+//#include "bmesh.h"
 
 class AutoseamEigenspace
 {

Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.cpp       
2011-06-22 01:04:01 UTC (rev 37721)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.cpp       
2011-06-22 04:23:34 UTC (rev 37722)
@@ -27,6 +27,44 @@
  */
 #include "AutoseamUtility.h"
 
+void depth_first_search(const MatrixXd& adjacency, int u, GraphNodeColor 
state[]) 
+{
+    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);
+            }
+        }
+    }
+    state[u] = Black;
+}
+
+bool is_graph_connected(const MatrixXd& adjacency) 
+{
+    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);
+        bool connected = true;
+        for (int i = 0; i < nNodes; i++) {
+            if ( state[i] != Black ) {
+                connected = false;
+                break;
+            }
+        }
+        delete [] state;
+        return connected;
+    } else {
+        return false;
+    }
+}
+
+
 AutoseamUtility::AutoseamUtility()
 {
        m_A <<  1.0f, 2.0f, 0.0f,

Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.h 
2011-06-22 01:04:01 UTC (rev 37721)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.h 
2011-06-22 04:23:34 UTC (rev 37722)
@@ -36,9 +36,11 @@
 
 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[]);
 
 
-
 class AutoseamUtility
 {
        public:
@@ -52,43 +54,7 @@
 
 };
 
-enum GraphNodeColor { White, Gray, Black };
 
-static void depth_first_search(const MatrixXd& adjacency, int u, 
GraphNodeColor state[]) 
-{
-    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);
-            }
-        }
-    }
-    state[u] = Black;
-}
 
-static bool is_graph_connected(const MatrixXd& adjacency) 
-{
-    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);
-        bool connected = true;
-        for (int i = 0; i < nNodes; i++) {
-            if ( state[i] != Black ) {
-                connected = false;
-                break;
-            }
-        }
-        delete [] state;
-        return connected;
-    } else {
-        return false;
-    }
-}
 
 #endif
\ No newline at end of file

Modified: branches/soc-2011-avocado/blender/intern/autoseam/CMakeLists.txt
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/CMakeLists.txt    
2011-06-22 01:04:01 UTC (rev 37721)
+++ branches/soc-2011-avocado/blender/intern/autoseam/CMakeLists.txt    
2011-06-22 04:23:34 UTC (rev 37722)
@@ -26,6 +26,7 @@
 
 set(INC
         ../../extern/Eigen3
+        ../../source/blender/bmesh
 )
 
 set(SRC

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-22 01:04:01 UTC (rev 37721)
+++ 
branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c  
    2011-06-22 04:23:34 UTC (rev 37722)
@@ -64,12 +64,26 @@
 }
 
 /* ------------------------ Code from Andrea ------------------------ */
+static int find_index(int index, int* face_indices, int nindices)
+{
+       int found = 0;
+       int i;
+       for (i=0; i<nindices; ++i) {
+               if (index == face_indices[i]) {
+                       found = 1;
+                       break;
+               }
+       }
+       return found;
+}
+
 static void autoseam_mark_seam(BMesh *bm, int *fplus, unsigned int nplus, int* 
fminus, unsigned int nminus)
 {
     BMEdge *edge;
     BMFace *face;
+       BMFace *other_face;
     BMIter edge_iter, face_iter;
-    int i;
+
     
     for(edge = BMIter_New(&edge_iter, bm, BM_EDGES_OF_MESH, NULL ); edge; 
edge= BMIter_Step(&edge_iter)) 
     {
@@ -80,28 +94,30 @@
     {
         if(!BM_Boundary_Edge(edge)){
             int bPlus = 0;
-            int bMinus = 0;
-            for (face=BMIter_New(&face_iter,bm, BM_FACES_OF_EDGE, edge); face; 
face=BMIter_Step(&face_iter)) {
-                int fidx = BM_GetIndex(face);
-                for (i=0; i<nplus; ++i) {
-                    if (fidx == fplus[i]) {
-                        bPlus = 1;
-                    }
-                }
-                /* added this if condition to avoid some unnecessary 
computation.*/
-                if(bPlus){
-                    for (i=0; i<nminus; ++i) {
-                        if (fidx == fminus[i]) {
-                            bMinus = 1;
-                        }
-                    }
-                }
+            int bSeam = 0;
+                       face=BMIter_New(&face_iter,bm, BM_FACES_OF_EDGE, edge);
+                       if (face) {
+                               int idx1 = BM_GetIndex(face);
+                               bPlus = find_index(idx1, fplus, nplus);
+                               other_face = face=BMIter_Step(&face_iter);
+                               while (other_face && !bSeam) {
+                                       int idx2 = BM_GetIndex(other_face);
+                                       if (bPlus) {
+                                               /* first face is in F+, so we 
look for face in F- for the seam */
+                                               bSeam = find_index(idx2, 
fminus, nminus);
+                                       } else {
+                                               /* first face is in F-, so we 
look for face in F+ for the seam */
+                                               bSeam = find_index(idx2, fplus, 
nplus);
+                                       }
+                                       other_face=BMIter_Step(&face_iter);
+                               }
             }
-            if (bPlus && bMinus) BM_SetHFlag(edge, BM_SEAM);
+            if (bSeam) BM_SetHFlag(edge, BM_SEAM);
         }
     }
 }
 
+
 static void autoseam_prepare_graph(BMesh *bm)
 {
     BMFace *face;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to