K3dPoly.h

Go to the documentation of this file.
00001 
00012 /***************************************************************************
00013  *   Copyright (C) 2007 by Jan Koci   *
00014  *   honza.koci@email.cz   *
00015  *   http://kengine.sourceforge.net/tutorial/
00016  *                                                                         *
00017  *   This program is free software; you can redistribute it and/or modify  *
00018  *   it under the terms of the GNU General Public License as published by  *
00019  *   the Free Software Foundation; either version 2 of the License, or     *
00020  *   (at your option) any later version.                                   *
00021  *                                                                         *
00022  *   This program is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00025  *   GNU General Public License for more details.                          *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU General Public License     *
00028  *   along with this program; if not, write to the                         *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00031  ***************************************************************************/
00032 
00033 #pragma once
00034 
00035 #include "../MathCore/K3dVector3.h"
00036 #include "K3dLineObj.h"
00037 #include "K3dPolyPlane.h"
00038 
00039 class K3dPoly
00040 {
00041                 TVertexArray m_vVertex;                                 
00042                 TLineArray m_vEdge;                                             
00043                 TPolyPlaneArray m_vPlane;                               
00044                 TVertexArray::iterator m_itVertex;              
00045                 TLineArray::iterator m_itEdge;                  
00046                 TPolyPlaneArray::iterator m_itPlane;    
00047         public:
00048                 K3dPoly();
00049                 ~K3dPoly();
00050 
00051                 void DeletePoly();
00052 
00054                 TVertexArray &GetVertexArray()
00055                 {
00056                         return m_vVertex;
00057                 }
00058 
00060                 void AddVertex ( K3dVertexObj *_pVertex )
00061                 {
00062                         // If vertex doesn`t in the array
00063                         m_itVertex= find ( m_vVertex.begin(), m_vVertex.end(), _pVertex );
00064                         if ( m_itVertex == m_vVertex.end() )
00065                         {
00066                                 // Add vertex to the vertex array
00067                                 m_vVertex.push_back ( _pVertex );
00068                         }
00069                 }
00070 
00072                 void DeleteVertex ( K3dVertexObj *_pVertex )
00073                 {
00074                         m_itVertex = find ( m_vVertex.begin(), m_vVertex.end(), _pVertex );
00075                         if ( m_itVertex != m_vVertex.end() )
00076                         {
00077                                 m_vVertex.erase ( m_itVertex );
00078                         }
00079                         else
00080                         {
00081                                 cerr <<  "Error - K3dPoly::DeleteVertex() -- Vertex  " << _pVertex << " doesn't exists " << endl;
00082                         }
00083                 }
00084 
00086                 TLineArray &GetEdgeArray()
00087                 {
00088                         return m_vEdge;
00089                 }
00090 
00092                 void AddEdge ( K3dLineObj *_pEdge )
00093                 {
00094                         // If edge doesn`t in the array
00095                         m_itEdge = find ( m_vEdge.begin(), m_vEdge.end(), _pEdge );
00096                         if ( m_itEdge == m_vEdge.end() )
00097                         {
00098                                 // Add edge to the edge array
00099                                 m_vEdge.push_back ( _pEdge );
00100                         }
00101                 }
00102 
00104                 void DeleteEdge ( K3dLineObj *_pEdge )
00105                 {
00106                         m_itEdge = find ( m_vEdge.begin(), m_vEdge.end(), _pEdge );
00107                         if ( m_itEdge != m_vEdge.end() )
00108                         {
00109                                 m_vEdge.erase ( m_itEdge );
00110                         }
00111                         else
00112                         {
00113                                 cerr <<  "K3dPoly::DeleteEdge -- Edge " << _pEdge << " doesn't exists " << endl;
00114                         }
00115                 }
00116 
00118                 TPolyPlaneArray &GetPlaneArray()
00119                 {
00120                         return m_vPlane;
00121                 }
00122 
00124                 void AddPlane ( K3dPolyPlane *_pPlane )
00125                 {
00126                         // If plane doesn`t in the array
00127                         m_itPlane = find ( m_vPlane.begin(), m_vPlane.end(), _pPlane );
00128                         if ( m_itPlane == m_vPlane.end() )
00129                         {
00130                                 // Add plane to the array
00131                                 m_vPlane.push_back ( _pPlane );
00132                         }
00133                 }
00134 
00136                 void DeletePlane ( K3dPolyPlane *_pPlane )
00137                 {
00138                         m_itPlane = find ( m_vPlane.begin(), m_vPlane.end(), _pPlane );
00139                         if ( m_itPlane != m_vPlane.end() )
00140                         {
00141                                 m_vPlane.erase ( m_itPlane );
00142                         }
00143                         else
00144                         {
00145                                 cerr <<  "K3dPoly::DeletePlane -- Plane " << _pPlane << " doesn't exists " << endl;
00146                         }
00147                 }
00148 };
00149 
00150 

Generated on Thu Aug 16 23:53:26 2007 for K3dEngine by  doxygen 1.5.0