[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38101] branches/soc-2011-avocado/blender: Unwrap functionality inside the generate seam operator is integrated and indentation issues regarding mixed tab and spaces are fixed .
shuvro sarker
shuvro05 at gmail.com
Tue Jul 5 03:42:57 CEST 2011
Revision: 38101
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38101
Author: shuvro
Date: 2011-07-05 01:42:54 +0000 (Tue, 05 Jul 2011)
Log Message:
-----------
Unwrap functionality inside the generate seam operator is integrated and indentation issues regarding mixed tab and spaces are fixed.
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/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/include/ED_uvedit.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-05 00:30:27 UTC (rev 38100)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.cpp 2011-07-05 01:42:54 UTC (rev 38101)
@@ -5,72 +5,72 @@
#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;
+ 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)
{
- m_adjacency(row, col) = value;
- m_adjacency(col, row) = value;
+ m_adjacency(row, col) = value;
+ m_adjacency(col, row) = value;
}
void AutoseamAdjacency::set_min_value(float min_value)
{
- threshold_value = min_value;
+ threshold_value = min_value;
}
int AutoseamAdjacency::is_adjacent(int row, int col)
{
- return m_adjacency(row, col) > THRESHOLD_ZERO ? 1 : 0;
+ return m_adjacency(row, col) > THRESHOLD_ZERO ? 1 : 0;
}
void AutoseamAdjacency::set_map_default()
{
- int i;
- int rows = m_adjacency.rows();
- for(i = 0; i < rows; i++){
- set_mapping(i, i);
- }
+ int i;
+ int rows = m_adjacency.rows();
+ for(i = 0; i < rows; i++){
+ set_mapping(i, i);
+ }
}
float AutoseamAdjacency::get_value(int row, int col)
{
- return m_adjacency(row,col);
+ return m_adjacency(row,col);
}
AutoseamAdjacency::~AutoseamAdjacency()
{
- clear_eigenspaces();
+ clear_eigenspaces();
}
void AutoseamAdjacency::clear_eigenspaces()
{
- for (std::vector<AutoseamEigenspace*>::iterator it = m_eigenspaces.begin(); it != m_eigenspaces.end(); ++it)
- {
- delete (*it);
- }
- m_eigenspaces.clear();
+ for (std::vector<AutoseamEigenspace*>::iterator it = m_eigenspaces.begin(); it != m_eigenspaces.end(); ++it)
+ {
+ delete (*it);
+ }
+ m_eigenspaces.clear();
}
void AutoseamAdjacency::set_mapping(int index, int value)
{
- //m_index_map[index] = value;
- m_index_map_vector[index] = value;
+ //m_index_map[index] = value;
+ m_index_map_vector[index] = value;
}
int AutoseamAdjacency::get_mapping(int index)
{
- if(m_index_map_vector[index] != -1){
- return m_index_map_vector[index];
- }
- else{
- printf("No value present for index %d\n", index);
- return -1;
- }
+ if(m_index_map_vector[index] != -1){
+ return m_index_map_vector[index];
+ }
+ else{
+ printf("No value present for index %d\n", index);
+ return -1;
+ }
}
//int AutoseamAdjacency::is_adjacent(int index1, int index2)
@@ -81,113 +81,113 @@
bool AutoseamAdjacency::generate_seam()
{
- MatrixXd& a = m_adjacency;
+ MatrixXd& a = m_adjacency;
- clear_eigenspaces();
+ clear_eigenspaces();
- int n = a.rows();
- for (int i=0; i<n;++i) {
- a(i,i) = 0.0;
- double rowsum = a.row(i).sum();
- a(i,i) = -rowsum;
- }
-
- if(a.rows() && a.cols()){
-
- Eigen::SelfAdjointEigenSolver<MatrixXd> es(a);
- Eigen::VectorXd evalues(es.eigenvalues());
- int f = 0;
- bool found = false;
+ int n = a.rows();
+ for (int i=0; i<n;++i) {
+ a(i,i) = 0.0;
+ double rowsum = a.row(i).sum();
+ a(i,i) = -rowsum;
+ }
+
+ if(a.rows() && a.cols()){
+
+ Eigen::SelfAdjointEigenSolver<MatrixXd> es(a);
+ Eigen::VectorXd evalues(es.eigenvalues());
+ int f = 0;
+ bool found = false;
- MatrixXd aplus;
- MatrixXd aminus;
-
- 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(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);
-
+ MatrixXd aplus;
+ MatrixXd aminus;
+
+ 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(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, threshold_value) && is_graph_connected(aminus, threshold_value))) {
- m_eigenspaces.push_back(aes);
- found = true;
- }
- else {
- delete aes;
- }
-
- }
- f++;
- }
- return found;
- }
- return 0;
+ // We filter out eigenspaces that give non-connected F+ and F- as in the paper
+ if ((is_graph_connected(aplus, threshold_value) && is_graph_connected(aminus, threshold_value))) {
+ m_eigenspaces.push_back(aes);
+ found = true;
+ }
+ else {
+ delete aes;
+ }
+
+ }
+ f++;
+ }
+ return found;
+ }
+ return 0;
}
int AutoseamAdjacency::get_num_splits()
{
- return m_eigenspaces.size();
+ return m_eigenspaces.size();
}
void AutoseamAdjacency::get_split(int n, int *fplus, unsigned int* nplus, int* fminus, unsigned int* nminus)
{
- int i;
- int face_index;
-
- if(m_eigenspaces.size()){
- m_eigenspaces[n]->get(fplus, nplus, fminus, nminus);
-
- /* pack the original indexes. */
- for(i = 0; i < *nplus; i++){
- face_index = get_mapping(fplus[i]);
- if(face_index != -1){
- fplus[i] = get_mapping(fplus[i]);
- }
- else{
- printf("error in getting mapping. May be mapping is not done.\n");
- }
- }
-
- for(i = 0; i < *nminus; i++){
- face_index = get_mapping(fminus[i]);
-
- if(face_index != -1){
- fminus[i] = get_mapping(fminus[i]);
- }
- else{
- printf("error in getting mapping. May be mapping is not done.\n");
- }
-
- }
- }
- else{
- *nplus = 0;
- *nminus = 0;
- printf("No seam generation is possible");
- }
+ int i;
+ int face_index;
+
+ if(m_eigenspaces.size()){
+ m_eigenspaces[n]->get(fplus, nplus, fminus, nminus);
+
+ /* pack the original indexes. */
+ for(i = 0; i < *nplus; i++){
+ face_index = get_mapping(fplus[i]);
+ if(face_index != -1){
+ fplus[i] = get_mapping(fplus[i]);
+ }
+ else{
+ printf("error in getting mapping. May be mapping is not done.\n");
+ }
+ }
+
+ for(i = 0; i < *nminus; i++){
+ face_index = get_mapping(fminus[i]);
+
+ if(face_index != -1){
+ fminus[i] = get_mapping(fminus[i]);
+ }
+ else{
+ printf("error in getting mapping. May be mapping is not done.\n");
+ }
+
+ }
+ }
+ else{
+ *nplus = 0;
+ *nminus = 0;
+ printf("No seam generation is possible");
+ }
}
// get the longest seam with connected subgraphs F+ and F-
int AutoseamAdjacency::get_best_split()
{
- float max_length= 0;
- int best= 0;
-
- for (int i=0; i < m_eigenspaces.size(); ++i) {
- AutoseamEigenspace* aes = m_eigenspaces[i];
- float len = aes->get_seam_length(m_adjacency);
- if (len>max_length) {
- max_length = len;
- best = i;
- }
- }
- return best;
+ float max_length= 0;
+ int best= 0;
+
+ for (int i=0; i < m_eigenspaces.size(); ++i) {
+ AutoseamEigenspace* aes = m_eigenspaces[i];
+ float len = aes->get_seam_length(m_adjacency);
+ if (len>max_length) {
+ max_length = len;
+ best = i;
+ }
+ }
+ return best;
}
void AutoseamAdjacency::debug(std::ofstream& fout)
@@ -200,7 +200,7 @@
}
fout << std::endl;
for (int i=0; i < m_eigenspaces.size(); ++i) {
- AutoseamEigenspace* aes = m_eigenspaces[i];
+ AutoseamEigenspace* aes = m_eigenspaces[i];
aes->debug(fout);
}
}
\ No newline at end of file
Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.h 2011-07-05 00:30:27 UTC (rev 38100)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.h 2011-07-05 01:42:54 UTC (rev 38101)
@@ -10,33 +10,33 @@
class AutoseamAdjacency
{
- public:
- AutoseamAdjacency(int dimension);
- ~AutoseamAdjacency();
-
- void set_min_value(float min_value);
- void set(int row, int col, float value);
- int is_adjacent(int row, int col);
- const Eigen::MatrixXd& getMatrix() const { return m_adjacency; }
- bool generate_seam();
- 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);
- 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);
-
+ public:
+ AutoseamAdjacency(int dimension);
+ ~AutoseamAdjacency();
+
+ void set_min_value(float min_value);
+ void set(int row, int col, float value);
+ int is_adjacent(int row, int col);
+ const Eigen::MatrixXd& getMatrix() const { return m_adjacency; }
+ bool generate_seam();
+ 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);
+ void set_mapping(int index, int value);
+ int get_mapping(int index);
+ void set_map_default();
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list