summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmface.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/pmface.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/pmface.cpp')
-rw-r--r--kpovmodeler/pmface.cpp119
1 files changed, 119 insertions, 0 deletions
diff --git a/kpovmodeler/pmface.cpp b/kpovmodeler/pmface.cpp
new file mode 100644
index 00000000..654a31b0
--- /dev/null
+++ b/kpovmodeler/pmface.cpp
@@ -0,0 +1,119 @@
+/*
+**************************************************************************
+ description
+ --------------------
+ copyright : (C) 2004 by Leon Pennington
+**************************************************************************
+
+**************************************************************************
+* *
+* 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 <new>
+#include "pmface.h"
+
+GLuint PMFace::s_dummy = 0;
+
+PMFace::PMFace( const PMFace& face )
+{
+ m_points = new( std::nothrow ) GLuint[ face.m_size ];
+ for( unsigned i = 0; i < face.m_size; ++i )
+ m_points[ i ] = face.m_points[ i ];
+ m_size = face.m_size;
+ m_normal = face.m_normal;
+}
+
+PMFace::PMFace( const GLuint pt1, const GLuint pt2, const GLuint pt3, const PMVector& normal )
+{
+ m_points = new( std::nothrow ) GLuint[ 3 ];
+ m_points[ 0 ] = pt1;
+ m_points[ 1 ] = pt2;
+ m_points[ 2 ] = pt3;
+ m_size = 3;
+ m_normal = normal;
+}
+
+PMFace::PMFace( const GLuint pt1, const GLuint pt2, const GLuint pt3, const GLuint pt4, const PMVector& normal )
+{
+ m_points = new( std::nothrow ) GLuint[ 4 ];
+ m_points[ 0 ] = pt1;
+ m_points[ 1 ] = pt2;
+ m_points[ 2 ] = pt3;
+ m_points[ 3 ] = pt4;
+ m_size = 4;
+ m_normal = normal;
+}
+
+PMFace& PMFace::operator=( const PMFace& face )
+{
+ delete m_points;
+ m_points = new( std::nothrow ) GLuint[ face.m_size ];
+ for( unsigned i = 0; i < face.m_size; ++i )
+ m_points[ i ] = face.m_points[ i ];
+ m_size = face.m_size;
+ m_normal = face.m_normal;
+ return *this;
+}
+
+bool PMFace::operator==( const PMFace& face ) const
+{
+ if( m_size == face.m_size && m_normal == face.m_normal )
+ {
+ for( unsigned i = 0; i < m_size; ++i )
+ {
+ if( m_points[i] != face.m_points[i] )
+ return false;
+ }
+ return true;
+ }
+ else
+ return false;
+}
+
+bool PMFace::operator!=( const PMFace& face ) const
+{
+ return !( *this == face );
+}
+
+bool PMFace::resize( const unsigned int size )
+{
+ if( size != m_size )
+ {
+ GLuint* temp = new( std::nothrow ) GLuint[ size ];
+ if( temp )
+ {
+ for( unsigned i = 0; i < m_size && i < size; ++i )
+ temp[i] = m_points[i];
+
+ for( unsigned i = m_size; i < size; ++i )
+ temp[i] = 0;
+
+ delete [] m_points;
+ m_points = temp;
+ }
+ else
+ return false;
+ }
+ return true;
+}
+
+GLuint& PMFace::operator[] ( int index )
+{
+ if( ( index >= 0 ) && ( index < ( signed ) m_size ) )
+ return m_points[index];
+ kdError( PMArea ) << "Bad index in PMFace operator []\n";
+ return s_dummy;
+}
+
+const GLuint& PMFace::operator[] ( int index ) const
+{
+ if( ( index >= 0 ) && ( index < ( signed ) m_size ) )
+ return m_points[index];
+ kdError( PMArea ) << "Bad index in PMFace operator []\n";
+ return s_dummy;
+}