vcglib/apps/nexus/vert_remap.cpp

87 lines
3.1 KiB
C++
Raw Normal View History

2004-06-24 16:32:45 +02:00
/****************************************************************************
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
* All rights reserved. *
* *
* 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. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. *
* *
****************************************************************************/
/****************************************************************************
History
$Log: not supported by cvs2svn $
2004-07-02 15:01:28 +02:00
Revision 1.2 2004/07/01 21:36:30 ponchio
Various debug
2004-07-01 23:36:30 +02:00
Revision 1.1 2004/06/24 14:32:45 ponchio
Moved from wrap/nexus
2004-06-24 16:32:45 +02:00
Revision 1.1 2004/06/24 14:18:58 ponchio
Created
****************************************************************************/
#include <iostream>
#include "vert_remap.h"
using namespace std;
using namespace nxs;
bool VertRemap::Create(const std::string &file) {
2004-07-02 15:01:28 +02:00
if(!all.Create(file + ".rmv")) return false;
if(!borders.Create(file + ".rmb")) return false;
2004-06-24 16:32:45 +02:00
return true;
}
bool VertRemap::Load(const std::string &file) {
2004-07-02 15:01:28 +02:00
if(!all.Load(file + ".rmv")) return false;
if(!borders.Load(file + ".rmb")) return false;
2004-06-24 16:32:45 +02:00
return true;
}
void VertRemap::Resize(unsigned int n_vert) {
all.Resize(n_vert);
for(unsigned int i = 0; i < n_vert; i++)
all[i] = 0xffffffff;
borders.Clear();
borders.Resize(n_vert/10);
}
unsigned int VertRemap::Size() {
return all.Size();
}
unsigned int VertRemap::Count(unsigned int key) {
assert(key < Size());
if(all[key] == 0xffffffff) return 0;
return 1 + borders.Count(key);
}
void VertRemap::Insert(unsigned int key, unsigned int value) {
2004-07-01 23:36:30 +02:00
if(all[key] == 0xffffffff) {
2004-06-24 16:32:45 +02:00
all[key] = value;
2004-07-01 23:36:30 +02:00
} else if(all[key] != value) {
2004-06-24 16:32:45 +02:00
borders.Insert(key, value);
2004-07-01 23:36:30 +02:00
}
2004-06-24 16:32:45 +02:00
}
unsigned int VertRemap::GetValue(unsigned int key) { //return first value
assert(key < Size());
return all[key];
}