[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39382] branches/soc-2011-avocado/blender: Some code clean up, fix of one crash due to setting wrong values of number of eigen values, added live unwrap functionality as an option of autoseam, added some class level comment, a fix of recursive stretch calculation.

shuvro sarker shuvro05 at gmail.com
Sun Aug 14 07:18:12 CEST 2011


Revision: 39382
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39382
Author:   shuvro
Date:     2011-08-14 05:18:11 +0000 (Sun, 14 Aug 2011)
Log Message:
-----------
Some code clean up, fix of one crash due to setting wrong values of number of eigen values, added live unwrap functionality as an option of autoseam, added some class level comment, a fix of recursive stretch calculation.

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/AutoseamEigenspace.h
    branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.cpp
    branches/soc-2011-avocado/blender/intern/autoseam/EigenSolverArpack.cpp
    branches/soc-2011-avocado/blender/intern/autoseam/EigenSolverArpack.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-08-14 04:55:52 UTC (rev 39381)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.cpp	2011-08-14 05:18:11 UTC (rev 39382)
@@ -183,7 +183,7 @@
 	return m_eigenspaces.size();
 }
 
-void AutoseamAdjacency::get_split(int n, int *fplus, unsigned int* nplus, int* fminus, unsigned int* nminus)
+int AutoseamAdjacency::get_split(int n, int *fplus, unsigned int* nplus, int* fminus, unsigned int* nminus)
 {
 	int i;
 	int face_index;
@@ -218,7 +218,10 @@
 		*nplus  = 0;
 		*nminus = 0;
 		printf("No seam generation is possible");
+		return 0;
 	}
+	
+	return 1;
 }
 
 // get the longest seam with connected subgraphs F+ and F-

Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.h	2011-08-14 04:55:52 UTC (rev 39381)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.h	2011-08-14 05:18:11 UTC (rev 39382)
@@ -47,11 +47,10 @@
 		void clear_eigenspaces();
 		int get_num_splits();
 		int get_best_split();
-		void get_split(int n, int *fplus, unsigned int* nplus, int* fminus, unsigned int* nminus);
+		int get_split(int n, int *fplus, unsigned int* nplus, int* fminus, unsigned int* nminus);
 		void set_mapping(int index, int value);
 		int  get_mapping(int index);
 		void set_map_default();
-		//int is_adjacent(int index1, int index2);
 		float get_value(int row, int col);
 	
 		void debug(std::ofstream& fout);
@@ -61,7 +60,6 @@
 		std::vector<AutoseamEigenspace*> m_eigenspaces;
 		std::vector<int> m_index_map_vector;
 		float threshold_value;
-		//map<int,int> m_index_map;
 		Eigen::VectorXd mul_vec;
 		int num_eigen_values;
 		int matrix_dimension;

Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.cpp	2011-08-14 04:55:52 UTC (rev 39381)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.cpp	2011-08-14 05:18:11 UTC (rev 39382)
@@ -24,14 +24,19 @@
  * Contributor(s): Shuvro Sarker
  *
  * ***** END GPL LICENSE BLOCK *****
+ * 
+ * This class deals with the tasks of filling adjacency matrix with mesh information, calucalte 
+ * seam length, spliting and getting seams.
  */
+ 
 
 #include <fstream>
 #include "AutoseamEigenspace.h"
 
 #define THRESHOLD_ZERO 0.0001
 
-//AutoseamEigenspace::AutoseamEigenspace(double eigenval, const Eigen::VectorXd& eigenvector)
+
+
 AutoseamEigenspace::AutoseamEigenspace(double eigenval, const std::vector<double>& eigenvector)
 : e(eigenval), v(eigenvector)
 {
@@ -95,7 +100,9 @@
 	*nminus = minus_size;
 }
 
-
+/** 
+ * Seam lengths can be assumed all equal or the geometric length.
+ */
 float AutoseamEigenspace::get_seam_length(const Eigen::MatrixXd& adj)
 {
 	float count= 0;

Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.h	2011-08-14 04:55:52 UTC (rev 39381)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamEigenspace.h	2011-08-14 05:18:11 UTC (rev 39382)
@@ -30,12 +30,11 @@
 
 #include <vector>
 #include "AutoseamUtility.h"
-//#include "bmesh.h"
 
+
 class AutoseamEigenspace
 {
 	public:
-		//AutoseamEigenspace(double eigenval, const Eigen::VectorXd& eigenvector);
 		AutoseamEigenspace(double eigenval, const std::vector<double>& eigenvector);
 		void split();
 		void fill_adjacency(const Eigen::MatrixXd& adj, Eigen::MatrixXd& adj_plus, Eigen::MatrixXd& adj_minus);
@@ -46,7 +45,6 @@
 
 	private:
 		double e;
-		//Eigen::VectorXd v;
 		std::vector<double> v;
 	
 		std::vector<int> m_fplus;

Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.cpp	2011-08-14 04:55:52 UTC (rev 39381)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.cpp	2011-08-14 05:18:11 UTC (rev 39382)
@@ -35,7 +35,6 @@
 	for (int v = 0; v < nNodes; v++) {
 		if (u != v) {
 			double adj = adjacency(u, v);
-			//printf("min value: %lf",min_value);
 			if ((adj >= min_value) && state[v] == White) {
 				depth_first_search(adjacency, v, state, min_value);
 			}
@@ -92,10 +91,7 @@
 	int i,l,r_index,c_index;
 	dualMatrix.resize(num_row, num_col);
 	
-	/* we can print the matrix here to have a look */
-	
-	/* the argument dual_matrix will not be provided as 2d array later, the data 
-	 structure will be improved for efficiency. */
+
 	for(c_index = 0; c_index < num_col; c_index++){
 		for(r_index = 0; r_index < num_row; r_index++){
 			if(dual_matrix[r_index][c_index] != 0.0){
@@ -111,9 +107,9 @@
 
 	// we need to replace this portion with our eigen generation code
 	Eigen::EigenSolver<MatrixXd> es(dualMatrix);
-	std::cout << "The eigenvalues of A are:" << std::endl << es.eigenvalues() << std::endl;
 	
 	
+	
 	/**
 	 * Pack the calculated eigen vectors and eigen values to 
 	 * eigen_vectors and eigen_values.
@@ -125,13 +121,11 @@
 		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/EigenSolverArpack.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/EigenSolverArpack.cpp	2011-08-14 04:55:52 UTC (rev 39381)
+++ branches/soc-2011-avocado/blender/intern/autoseam/EigenSolverArpack.cpp	2011-08-14 05:18:11 UTC (rev 39382)
@@ -38,8 +38,6 @@
 #include <stdexcept>
 
 
-//#define EIGEN_DEBUG_ARPACK 1
-//#define NUM_EIGEN_VAL 100
 #define NUM_EIGEN_VAL 40
 #define minimum(a,b)  (a <= b) ? a : b;
 
@@ -51,7 +49,7 @@
 
 EigenSolverArpack::~EigenSolverArpack()
 {
-	printf("Destructor is being called.");
+	
 }
 
 
@@ -118,10 +116,7 @@
 	doublereal *v = NULL;
 	doublereal *resid = NULL;
 	
-	
-	
-	
-	
+
 	// This is the dimension of the matrix
 	n = matrix_dimension;
 	
@@ -136,15 +131,17 @@
 	
 	ldv = (integer)matrix_dimension;
 	nev = minimum(matrix_dimension - 1, NUM_EIGEN_VAL);
-	//num_eigen_values = nev;
-	num_eigen_vectors = nev;
-	//ncv = minimum(nev + 1, n);
+
+	
+
 	ncv = nev*2.5;
 	if(ncv > matrix_dimension) { ncv = matrix_dimension ; }
 	if(nev > matrix_dimension) { nev = matrix_dimension ; }
 	if(nev + 2 > ncv) {  nev = ncv - 2 ;   } 
 	
+	num_eigen_vectors = nev;
 	
+	
 	*(unsigned char *)bmat = 'I';
 	
 	
@@ -222,7 +219,7 @@
 	if (info < 0) {
 		
 		// error occured
-		printf(" Error with _saupd, info = %d\n", info);
+		printf(" Error with _saupd, info = %ld\n", info);
 		printf(" Check documentation in _saupd \n");
 	} 
 	else {
@@ -248,7 +245,7 @@
 		
 		if (ierr != 0) {
 			
-			printf(" Error with _seupd, info = %d\n", ierr);
+			printf(" Error with _seupd, info = %ld\n", ierr);
 			printf(" Check the documentation of _seupd. \n");
 			
 		} 

Modified: branches/soc-2011-avocado/blender/intern/autoseam/EigenSolverArpack.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/EigenSolverArpack.h	2011-08-14 04:55:52 UTC (rev 39381)
+++ branches/soc-2011-avocado/blender/intern/autoseam/EigenSolverArpack.h	2011-08-14 05:18:11 UTC (rev 39382)
@@ -38,7 +38,6 @@
 	
 	public:
 		
-		//Eigen::VectorXd eigen_values;
 		EigenSolverArpack(int dimension);
 		eigen_vectors solve();
 		double eigenvalue(int n);

Modified: branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.cpp	2011-08-14 04:55:52 UTC (rev 39381)
+++ branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.cpp	2011-08-14 05:18:11 UTC (rev 39382)
@@ -26,6 +26,12 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
+/** 
+ * This class is responsible for the communication between the C codes of Blender and
+ * the C++ based codes of autoseam module.
+ */
+ 
+
 #include <fstream>
 #include "AutoseamUtility.h"
 #include "AutoseamAdjacency.h"
@@ -127,10 +133,10 @@
 	return adj->get_best_split();
 }
 
-void autoseam_get_split(AUTOSEAM_Adjacency handle, int n, int *fplus, unsigned int* nplus, int* fminus, unsigned int* nminus)
+int autoseam_get_split(AUTOSEAM_Adjacency handle, int n, int *fplus, unsigned int* nplus, int* fminus, unsigned int* nminus)
 {
 	AutoseamAdjacency *adj = reinterpret_cast<AutoseamAdjacency*>(handle);
-	adj->get_split(n, fplus,nplus, fminus,nminus);
+	return adj->get_split(n, fplus,nplus, fminus,nminus);
 }
 
 void autoseam_debug(AUTOSEAM_Adjacency handle, const char *filename)

Modified: branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.h	2011-08-14 04:55:52 UTC (rev 39381)
+++ branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.h	2011-08-14 05:18:11 UTC (rev 39382)
@@ -57,7 +57,7 @@
 int autoseam_generate_seam(AUTOSEAM_Adjacency handle); 
 int autoseam_get_num_splits(AUTOSEAM_Adjacency handle);
 int autoseam_get_best_split(AUTOSEAM_Adjacency handle);
-void autoseam_get_split(AUTOSEAM_Adjacency handle, int n, int *fplus, unsigned int* nplus, int* fminus, unsigned int* nminus);
+int autoseam_get_split(AUTOSEAM_Adjacency handle, int n, int *fplus, unsigned int* nplus, int* fminus, unsigned int* nminus);
 float autoseam_get_value(AUTOSEAM_Adjacency handle, int row, int col);
 void autoseam_set_map_default(AUTOSEAM_Adjacency handle);
 

Modified: branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list