[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36876] branches/soc-2011-avocado/blender/ intern: Initial autoseam commit

shuvro sarker shuvro05 at gmail.com
Tue May 24 20:06:12 CEST 2011


Revision: 36876
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36876
Author:   shuvro
Date:     2011-05-24 18:06:12 +0000 (Tue, 24 May 2011)
Log Message:
-----------
Initial autoseam commit

Added Paths:
-----------
    branches/soc-2011-avocado/blender/intern/autoseam/
    branches/soc-2011-avocado/blender/intern/autoseam/CMakeLists.txt
    branches/soc-2011-avocado/blender/intern/autoseam/DummyClass.cpp
    branches/soc-2011-avocado/blender/intern/autoseam/DummyClass.h
    branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.cpp
    branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.h

Added: branches/soc-2011-avocado/blender/intern/autoseam/CMakeLists.txt
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/CMakeLists.txt	                        (rev 0)
+++ branches/soc-2011-avocado/blender/intern/autoseam/CMakeLists.txt	2011-05-24 18:06:12 UTC (rev 36876)
@@ -0,0 +1,38 @@
+# $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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# The Original Code is Copyright (C) 2011, Blender Foundation
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): none so far
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+        ../../extern/Eigen3
+)
+
+set(SRC
+	DummyClass.cpp
+	autoseam_C_API.cpp
+	DummyClass.h
+	autoseam_C_API.h
+)
+
+blender_add_lib(bf_intern_autoseam "${SRC}" "${INC}")

Added: branches/soc-2011-avocado/blender/intern/autoseam/DummyClass.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/DummyClass.cpp	                        (rev 0)
+++ branches/soc-2011-avocado/blender/intern/autoseam/DummyClass.cpp	2011-05-24 18:06:12 UTC (rev 36876)
@@ -0,0 +1,56 @@
+#include <Eigen/Core>
+#include <Eigen/Dense>
+#include <Eigen/Eigenvalues> 
+
+
+#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;
+}
+
+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];
+}
+

Added: branches/soc-2011-avocado/blender/intern/autoseam/DummyClass.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/DummyClass.h	                        (rev 0)
+++ branches/soc-2011-avocado/blender/intern/autoseam/DummyClass.h	2011-05-24 18:06:12 UTC (rev 36876)
@@ -0,0 +1,22 @@
+#ifndef DUMMY_CLASS_H_INCLUDED
+#define DUMMY_CLASS_H_INCLUDED
+
+#include <Eigen/Core>
+
+class DummyClass
+{
+	public:
+		DummyClass();
+		
+		void solve3x3(float *vec);
+		void get_solution(float *vec);
+	private:
+		Eigen::Matrix3f m_A;
+		Eigen::Vector3f m_x;
+    
+
+    
+    
+};
+
+#endif
\ No newline at end of file

Added: branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.cpp	                        (rev 0)
+++ branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.cpp	2011-05-24 18:06:12 UTC (rev 36876)
@@ -0,0 +1,27 @@
+
+#include "DummyClass.h"
+#include "autoseam_C_API.h"
+
+AUTOSEAM_DummyClassHandle autoseam_create_dummyclass()
+{
+	DummyClass *dummy = new DummyClass();
+	return (AUTOSEAM_DummyClassHandle) dummy;
+}
+
+void autoseam_delete_dummyclass(AUTOSEAM_DummyClassHandle handle)
+{
+	DummyClass *dummy = reinterpret_cast<DummyClass*>(handle);
+	delete dummy;
+}
+
+void autoseam_solve3x3(AUTOSEAM_DummyClassHandle handle, float* vec)
+{
+	DummyClass *dummy = reinterpret_cast<DummyClass*>(handle);
+	dummy->solve3x3(vec);
+}
+
+void autoseam_get_solution(AUTOSEAM_DummyClassHandle handle, float* vec)
+{
+	DummyClass *dummy = reinterpret_cast<DummyClass*>(handle);
+	dummy->get_solution(vec);
+}
\ No newline at end of file

Added: branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.h	                        (rev 0)
+++ branches/soc-2011-avocado/blender/intern/autoseam/autoseam_C_API.h	2011-05-24 18:06:12 UTC (rev 36876)
@@ -0,0 +1,24 @@
+#ifndef AUTOSEAM_C_API_INCLUDED
+#define AUTOSEAM_C_API_INCLUDED
+
+// simple c function
+
+#ifdef __cplusplus // so we can include the header form C++ as well
+extern "C" {
+#endif 
+
+// This is to simplify passing pointers to classes back into the API
+#define AUTOSEAM_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
+AUTOSEAM_DECLARE_HANDLE(AUTOSEAM_DummyClassHandle);
+
+AUTOSEAM_DummyClassHandle autoseam_create_dummyclass();
+void autoseam_delete_dummyclass(AUTOSEAM_DummyClassHandle handle);
+
+void autoseam_solve3x3(AUTOSEAM_DummyClassHandle handle, float* vec);
+void autoseam_get_solution(AUTOSEAM_DummyClassHandle handle, float* vec);
+
+#ifdef __cplusplus
+}
+#endif 
+
+#endif




More information about the Bf-blender-cvs mailing list