[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37310] branches/soc-2011-avocado/blender: Fixed memory issues, some refactoring done and now the code is able to working of any number of faces as long as eigen3 can calculate the eigen values of it .

shuvro sarker shuvro05 at gmail.com
Wed Jun 8 06:17:52 CEST 2011


Revision: 37310
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37310
Author:   shuvro
Date:     2011-06-08 04:17:50 +0000 (Wed, 08 Jun 2011)
Log Message:
-----------
Fixed memory issues, some refactoring done and now the code is able to  working of any number of faces as long as eigen3 can calculate the eigen values of it. Dummy codes removed.

Modified Paths:
--------------
    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/release/scripts/startup/bl_ui/space_view3d.py
    branches/soc-2011-avocado/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
    branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c
    branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.h
    branches/soc-2011-avocado/blender/source/blender/editors/mesh/mesh_intern.h
    branches/soc-2011-avocado/blender/source/blender/editors/mesh/mesh_ops.c

Added Paths:
-----------
    branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.cpp
    branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.h

Removed Paths:
-------------
    branches/soc-2011-avocado/blender/intern/autoseam/DummyClass.cpp
    branches/soc-2011-avocado/blender/intern/autoseam/DummyClass.h

Added: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.cpp	                        (rev 0)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.cpp	2011-06-08 04:17:50 UTC (rev 37310)
@@ -0,0 +1,97 @@
+/* $Id: 
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2011 by Shuvro Sarker.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Shuvro Sarker
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <Eigen/Core>
+#include <Eigen/Dense>
+#include <Eigen/Eigenvalues> 
+
+#include <iostream>
+
+#include "AutoseamUtility.h"
+
+using Eigen::MatrixXd;
+
+
+
+AutoseamUtility::AutoseamUtility()
+{
+	m_A <<  1.0f, 2.0f, 0.0f,
+			0.0f, 2.0f, 3.0f,
+			0.0f, 0.0f, 3.0f;
+}
+
+static double row_sum(MatrixXd matrix, int dimension, int row_index) {
+    double result = 0.0 ;
+   
+
+    for (int i = 0; i < dimension; i++) {
+        result += matrix(row_index, i);
+    }
+    return result ;
+}
+
+
+
+
+void AutoseamUtility::calculate_eigen(float **dual_matrix, int num_row, int num_col)
+{
+    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]){
+                dualMatrix(r_index, c_index) = dual_matrix[r_index][c_index];
+            }
+            else dualMatrix(r_index, c_index) = 0;
+        }
+    }
+    
+    for( l = 0; l < num_row; l++ ){
+        dualMatrix(l,l) = - row_sum(dualMatrix, num_row, l);
+    }
+    
+   Eigen::EigenSolver<MatrixXd> es(dualMatrix);
+   std::cout << "The eigenvalues of A are:" << std::endl << es.eigenvalues() << std::endl;
+    
+    
+   /* Now display the values. */
+    
+    for(i = 0; i < num_col; i++ )
+    {
+        std::cout << "Column "  << i << ": value " << es.eigenvalues()[i] << std::endl;
+        std::cout << "Column "  << i << ": vector " << es.eigenvectors().col(i) << std::endl;
+    }
+
+    
+}

Added: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.h	                        (rev 0)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamUtility.h	2011-06-08 04:17:50 UTC (rev 37310)
@@ -0,0 +1,53 @@
+/* $Id: 
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2011 by Shuvro Sarker.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Shuvro Sarker
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef DUMMY_CLASS_H_INCLUDED
+#define DUMMY_CLASS_H_INCLUDED
+
+#include <Eigen/Core>
+
+// XXXXX TODO_SHUVRO: Shouldn't we find a better name for this?
+class AutoseamUtility
+{
+	public:
+        AutoseamUtility();
+		
+		// XXXXX TODO_SHUVRO: remove the functions below that are not needed anymore
+
+        void calculate_eigen(float **dual_matrix, int num_row, int num_col);
+
+		Eigen::Matrix3f m_A;
+		Eigen::Vector3f m_x;
+        Eigen::MatrixXd dualMatrix;
+        
+        
+    
+
+};
+
+#endif
\ No newline at end of file

Deleted: branches/soc-2011-avocado/blender/intern/autoseam/DummyClass.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/DummyClass.cpp	2011-06-08 01:53:12 UTC (rev 37309)
+++ branches/soc-2011-avocado/blender/intern/autoseam/DummyClass.cpp	2011-06-08 04:17:50 UTC (rev 37310)
@@ -1,138 +0,0 @@
-/* $Id: 
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2011 by Shuvro Sarker.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Shuvro Sarker
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include <Eigen/Core>
-#include <Eigen/Dense>
-#include <Eigen/Eigenvalues> 
-
-#include <iostream>
-
-#include "DummyClass.h"
-
-using Eigen::MatrixXd;
-
-
-
-DummyClass::DummyClass()
-{
-	m_A <<  1.0f, 2.0f, 0.0f,
-			0.0f, 2.0f, 3.0f,
-			0.0f, 0.0f, 3.0f;
-}
-
-static double row_sum(MatrixXd matrix, int dimension, int row_index) {
-    double result = 0.0 ;
-   
-
-    for (int i = 0; i < dimension; i++) {
-        result += matrix(row_index, i);
-    }
-    return result ;
-}
-
-
-void DummyClass::solve3x3(float *vec)
-{
-	Eigen::Vector3f b;
-	b << vec[0], vec[1], vec[2];
-	//m_A.lu().solve(b, &m_x);
-    MatrixXd m(2,2);
-    m(0,0) = 3;
-    m(1,0) = 2.5;
-    m(0,1) = -1;
-    m(1,1) = m(1,0) + m(0,1);
-    std::cout << m << std::endl;
-    
-    
-   /* 
-    MatrixXd A = MatrixXd::Random(6,6);
-    
-
-    std::cout << "Here is a random 6x6 matrix, A:" << std::endl << A << std::endl << std::endl;
-    
-    Eigen::EigenSolver<MatrixXd> es(A);
-    std::cout << "The eigenvalues of A are:" << std::endl << es.eigenvalues() << std::endl;
-    std::cout << "The matrix of eigenvectors, V, is:" << std::endl << es.eigenvectors() << std::endl << std::endl;
-    
-    Eigen::complex<double> lambda = es.eigenvalues()[0];
-    std::cout << "Consider the first eigenvalue, lambda = " << lambda << std::endl;
-    Eigen::VectorXcd v = es.eigenvectors().col(0);
-    std::cout << "If v is the corresponding eigenvector, then lambda * v = " << std::endl << lambda * v << std::endl;
-    std::cout << "... and A * v = " << std::endl << A.cast<complex<double> >() * v << std::endl << std::endl;
-    
-    Eigen::MatrixXcd D = es.eigenvalues().asDiagonal();
-    Eigen::MatrixXcd V = es.eigenvectors();
-    std::cout << "Finally, V * D * V^(-1) = " <<     std::endl << V * D * V.inverse() <<     std::endl;*/
-
-}
-
-void DummyClass::get_solution(float *vec)
-{
-	vec[0] = m_x[0];
-	vec[1] = m_x[1];
-	vec[2] = m_x[2];
-}
-
-
-void DummyClass::calculate_eigen(float **dual_matrix, int num_row, int num_col)
-{
-    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]){
-                dualMatrix(r_index, c_index) = dual_matrix[r_index][c_index];
-            }
-            else dualMatrix(r_index, c_index) = 0;
-        }
-    }
-    
-    for( l = 0; l < num_row; l++ ){
-        dualMatrix(l,l) = - row_sum(dualMatrix, num_row, l);
-    }
-    
-   Eigen::EigenSolver<MatrixXd> es(dualMatrix);
-   std::cout << "The eigenvalues of A are:" << std::endl << es.eigenvalues() << std::endl;
-    
-    
-   /* Now display the values. */
-    
-    for(i = 0; i < num_col; i++ )
-    {
-        std::cout << "Column "  << i << ": value " << es.eigenvalues()[i] << std::endl;
-        std::cout << "Column "  << i << ": vector " << es.eigenvectors().col(i) << std::endl;
-    }
-
-    
-}

Deleted: branches/soc-2011-avocado/blender/intern/autoseam/DummyClass.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/DummyClass.h	2011-06-08 01:53:12 UTC (rev 37309)
+++ branches/soc-2011-avocado/blender/intern/autoseam/DummyClass.h	2011-06-08 04:17:50 UTC (rev 37310)
@@ -1,54 +0,0 @@
-/* $Id: 
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list