Blender V2.61 - r43446

BOP_Edge.cpp

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00033 #include "BOP_Edge.h"
00034 
00040 BOP_Edge::BOP_Edge(BOP_Index v1, BOP_Index v2) 
00041 {
00042     m_vertexs[0] = v1;
00043     m_vertexs[1] = v2;
00044 }
00045 
00050 void BOP_Edge::addFace(BOP_Index i) 
00051 {
00052     if (!containsFace(i))
00053         m_faces.push_back(i);
00054 }
00055 
00061 bool BOP_Edge::containsFace(BOP_Index i)
00062 {
00063     int pos=0;
00064     for(BOP_IT_Indexs it = m_faces.begin();it!=m_faces.end();pos++,it++) {
00065         if ((*it) == i)
00066         return true;
00067     }
00068     
00069     return false;
00070 }
00071 
00077 void BOP_Edge::replaceVertexIndex(BOP_Index oldIndex, BOP_Index newIndex) 
00078 {
00079     if (m_vertexs[0] == oldIndex) m_vertexs[0] = newIndex;
00080     else if (m_vertexs[1] == oldIndex) m_vertexs[1] = newIndex;
00081 }
00082 
00083 #ifdef BOP_NEW_MERGE
00084 
00090 bool BOP_Edge::removeFace(BOP_Index i)
00091 {
00092     int pos=0;
00093     for(BOP_IT_Indexs it = m_faces.begin();it!=m_faces.end();pos++,it++) {
00094         if ((*it) == i) {
00095             m_faces.erase(it);
00096             return true;
00097         }
00098     }
00099     
00100     return false;
00101 }
00102 
00103 #endif
00104 
00105 #ifdef BOP_DEBUG
00106 
00107 #include <iostream>
00108 
00112 ostream &operator<<(ostream &stream, BOP_Edge *e)
00113 {
00114     stream << "Edge[" << e->getVertex1() << "," << e->getVertex2();
00115 #ifdef BOP_NEW_MERGE
00116     if(e->m_used)
00117         stream << "] (used)";
00118     else
00119         stream << "] (unused)";
00120 #endif
00121     return stream;
00122 }
00123 #endif
00124 
00125