summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmpolynomexponents.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit47d455dd55be855e4cc691c32f687f723d9247ee (patch)
tree52e236aaa2576bdb3840ebede26619692fed6d7d /kpovmodeler/pmpolynomexponents.cpp
downloadtdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.tar.gz
tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kpovmodeler/pmpolynomexponents.cpp')
-rw-r--r--kpovmodeler/pmpolynomexponents.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/kpovmodeler/pmpolynomexponents.cpp b/kpovmodeler/pmpolynomexponents.cpp
new file mode 100644
index 00000000..fdda7bdf
--- /dev/null
+++ b/kpovmodeler/pmpolynomexponents.cpp
@@ -0,0 +1,71 @@
+/*
+**************************************************************************
+ description
+ --------------------
+ copyright : (C) 2002 by Andreas Zehender
+ email : zehender@kde.org
+**************************************************************************
+
+**************************************************************************
+* *
+* 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. *
+* *
+**************************************************************************/
+
+#include "pmpolynomexponents.h"
+#include "pmdebug.h"
+
+bool PMPolynomExponents::m_created[6] = { false, false, false,
+ false, false, false };
+QValueList<PMPolynomExponents> PMPolynomExponents::m_lists[6];
+
+PMPolynomExponents operator+ ( const PMPolynomExponents& p1,
+ const PMPolynomExponents& p2 )
+{
+ return PMPolynomExponents( p1.m_exponents[0] + p2.m_exponents[0],
+ p1.m_exponents[1] + p2.m_exponents[1],
+ p1.m_exponents[2] + p2.m_exponents[2] );
+}
+
+QValueList<PMPolynomExponents>& PMPolynomExponents::polynom( int n )
+{
+ if( ( n < 2 ) || ( n > 7 ) )
+ {
+ n = 2;
+ kdError( PMArea ) << "Wrong polynom order in PMPolynomExponents::polynom( )\n";
+ }
+
+ if( !m_created[n-2] )
+ {
+ m_lists[n-2] = recPolynom( PMPolynomExponents( 0, 0, 0 ), 0, n, 0 );
+ m_created[n-2] = true;
+// kdDebug( PMArea ) << "Polynom n: " << n << " size: " << m_lists[n-2].count( ) << endl;
+ }
+
+ return m_lists[n-2];
+}
+
+QValueList<PMPolynomExponents>
+PMPolynomExponents::recPolynom( const PMPolynomExponents& base,
+ int xyz, int n, int rem )
+{
+ QValueList<PMPolynomExponents> res;
+
+ if( n >= 0 )
+ {
+ if( ( ( rem + n ) == 0 ) || ( xyz > 2 ) )
+ res.append( base );
+ else
+ {
+ PMPolynomExponents newBase = base;
+ newBase.setExponent( xyz, n );
+ res += recPolynom( newBase, xyz + 1, rem, 0 );
+ res += recPolynom( base, xyz, n - 1, rem + 1 );
+ }
+ }
+
+ return res;
+}