2
* ***** BEGIN GPL LICENSE BLOCK *****
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19
* All rights reserved.
21
* The Original Code is: all of this file.
23
* Contributor(s): none yet.
25
* ***** END GPL LICENSE BLOCK *****
28
/** \file decimation/intern/LOD_MeshPrimitives.cpp
33
#include "LOD_MeshPrimitives.h"
35
#include "MT_assert.h"
36
#include "LOD_MeshException.h"
58
vector<LOD_EdgeInd>::iterator result = find(m_edges.begin(),m_edges.end(),e);
59
if (result == m_edges.end()) {
63
std::swap(*result, m_edges.back());
83
vector<LOD_EdgeInd>::iterator result =
84
find(m_edges.begin(),m_edges.end(),e_old);
85
if (result == m_edges.end()) {
87
LOD_MeshException e(LOD_MeshException::e_search_error);
113
return m_edges.empty();
121
pos.getValue(float_ptr);
132
m_verts[0] = m_verts[1] = LOD_VertexInd::Empty();
133
m_faces[0] = m_faces[1] = LOD_FaceInd::Empty();
141
// edges are the same if their vertex indices are the
142
// same!!! Other properties are not checked
146
if (this->m_verts[0] == rhs.m_verts[0]) {
149
if (this->m_verts[1] == rhs.m_verts[0]) {
152
if (this->m_verts[0] == rhs.m_verts[1]) {
155
if (this->m_verts[1] == rhs.m_verts[1]) {
165
// Elementary helper methods
166
////////////////////////////
173
if (f == m_faces[0]) {
176
if (f == m_faces[1]) {
180
LOD_MeshException e(LOD_MeshException::e_search_error);
183
return LOD_FaceInd::Empty();
193
if (old_f == m_faces[0]) {
196
if (old_f == m_faces[1]) {
199
LOD_MeshException e(LOD_MeshException::e_search_error);
205
// return the half edge face - the half edge is defined
206
// by the {vertex,edge} tuple.
213
if (vi == m_verts[0]) return m_faces[0];
214
if (vi == m_verts[1]) return m_faces[1];
217
LOD_MeshException e(LOD_MeshException::e_search_error);
220
return LOD_FaceInd::Empty();
229
if (vi == m_verts[0]) return m_verts[1];
230
if (vi == m_verts[1]) return m_verts[0];
233
LOD_MeshException e(LOD_MeshException::e_search_error);
236
return LOD_VertexInd::Empty();
239
// replace the vertex v_old with vertex v_new
240
// error if v_old is not one of the original vertices
248
if (v_old == m_verts[0]) {
251
if (v_old == m_verts[1]) {
257
LOD_MeshException e(LOD_MeshException::e_search_error);
260
if(m_verts[0] == m_verts[1]) {
263
LOD_MeshException e(LOD_MeshException::e_non_manifold);
273
return bool(m_verts[1].Tag() & 0x1);
281
m_verts[1].SetTag(int(tag));
288
return m_faces[0].Tag();
296
m_faces[0].SetTag(tag);
304
(m_faces[0].IsEmpty() && m_faces[1].IsEmpty()) ||
305
(m_verts[0] == m_verts[1])
315
m_verts[0] = m_verts[1] = m_verts[2] = LOD_VertexInd::Empty();
318
// Elementary helper methods
319
////////////////////////////
327
// could save branching here...
329
if (m_verts[0] == old_v) {
332
if (m_verts[1] == old_v) {
335
if (m_verts[2] == old_v) {
340
LOD_MeshException excep(LOD_MeshException::e_search_error);
349
return bool(m_verts[1].Tag() & 0x1);
357
m_verts[1].SetTag(int(tag));
364
return m_verts[2].Tag();
372
m_verts[2].SetTag(tag);
381
(m_verts[0] == m_verts[1]) ||
382
(m_verts[1] == m_verts[2]) ||
383
(m_verts[2] == m_verts[0])
392
index_ptr[0] = m_verts[0];
393
index_ptr[1] = m_verts[1];
394
index_ptr[2] = m_verts[2];