2005-02-08 13:43:03 +01: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 $
|
2005-02-19 11:45:05 +01:00
|
|
|
Revision 1.20 2005/02/08 12:43:03 ponchio
|
|
|
|
Added copyright
|
|
|
|
|
2005-02-08 13:43:03 +01:00
|
|
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
2004-07-02 15:00:02 +02:00
|
|
|
#ifndef NXS_NEXUS_H
|
|
|
|
#define NXS_NEXUS_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2005-01-14 16:25:29 +01:00
|
|
|
#include <list>
|
|
|
|
#include <map>
|
2004-10-08 16:46:26 +02:00
|
|
|
|
2005-01-14 16:25:29 +01:00
|
|
|
#include <vcg/space/sphere3.h>
|
|
|
|
|
|
|
|
#include "patch.h"
|
|
|
|
#include "index_file.h"
|
|
|
|
#include "history.h"
|
2004-10-08 16:46:26 +02:00
|
|
|
#include "borderserver.h"
|
2004-07-02 15:00:02 +02:00
|
|
|
|
|
|
|
namespace nxs {
|
|
|
|
|
2005-01-14 16:25:29 +01:00
|
|
|
/* Header fo nexus:
|
|
|
|
1Kb riservato per dati globali:
|
|
|
|
Magic: 'n' 'x' 's' 0x00
|
|
|
|
Signature: unsigned int (maschera di bit)
|
|
|
|
Chunk size: unsigned int
|
|
|
|
Index offset: unsigned int (offset to the index begin,
|
|
|
|
must be a multiple of chunk size)
|
|
|
|
History offset: unsigned int: multiple of chunk_size
|
|
|
|
|
|
|
|
Tot vert: unsigned int
|
|
|
|
Tot face: unsigned int
|
|
|
|
Bound sphere: Sphere3f (4 float: Point3f center (x, y, z), (radius))
|
|
|
|
|
|
|
|
11 * 4 = 44 bytes -> 4k per alignment purpoouses and reserving space. */
|
|
|
|
|
|
|
|
struct Entry {
|
|
|
|
unsigned int patch_start; //granularita' Chunk
|
|
|
|
unsigned short ram_size; //in chunks
|
|
|
|
unsigned short disk_size; // in chunks (used when compressed)
|
|
|
|
|
|
|
|
unsigned short nvert;
|
|
|
|
unsigned short nface;
|
|
|
|
|
|
|
|
vcg::Sphere3f sphere;
|
|
|
|
float error;
|
|
|
|
|
|
|
|
Patch *patch;
|
|
|
|
unsigned int vbo_array;
|
|
|
|
unsigned int vbo_element;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Nexus: public IndexFile<Entry> {
|
2004-07-02 15:00:02 +02:00
|
|
|
public:
|
2005-02-19 11:45:05 +01:00
|
|
|
enum Version { NXS_CURRENT_VERSION = 1 };
|
|
|
|
|
2005-01-14 16:25:29 +01:00
|
|
|
//HEader data:
|
|
|
|
Signature signature;
|
|
|
|
unsigned int chunk_size;
|
|
|
|
//unsigned int .IndexFile::offset;
|
|
|
|
int64 history_offset;
|
|
|
|
|
|
|
|
unsigned int totvert;
|
|
|
|
unsigned int totface;
|
|
|
|
vcg::Sphere3f sphere;
|
|
|
|
|
|
|
|
History history;
|
|
|
|
|
|
|
|
BorderServer borders;
|
|
|
|
|
2004-07-02 15:00:02 +02:00
|
|
|
|
2004-12-13 01:44:48 +01:00
|
|
|
Nexus() {}
|
|
|
|
~Nexus();
|
2004-10-08 16:46:26 +02:00
|
|
|
|
2005-02-19 11:45:05 +01:00
|
|
|
bool Create(const std::string &filename, Signature &signature,
|
2004-10-10 19:19:42 +02:00
|
|
|
unsigned int chunk_size = 1024);
|
2004-12-13 01:44:48 +01:00
|
|
|
bool Load(const std::string &filename, bool readonly = false);
|
|
|
|
void Close();
|
2005-01-14 16:25:29 +01:00
|
|
|
void Flush(bool all = true);
|
|
|
|
|
2004-10-08 16:46:26 +02:00
|
|
|
unsigned int AddPatch(unsigned int nv, unsigned int nf, unsigned int nb);
|
|
|
|
Patch &GetPatch(unsigned int patch, bool flush = true);
|
2005-01-21 18:09:13 +01:00
|
|
|
Border &GetBorder(unsigned int patch, bool flush = true);
|
2004-07-04 16:26:46 +02:00
|
|
|
|
2005-01-14 16:25:29 +01:00
|
|
|
unsigned int &MaxRam() { return ram_max; }
|
|
|
|
// void AddBorder(unsigned int patch, Link &link);
|
|
|
|
|
|
|
|
//move to nxsalgo!
|
|
|
|
void Unify(float threshold = 0.0f);
|
2004-11-18 19:30:15 +01:00
|
|
|
|
2005-02-19 11:45:05 +01:00
|
|
|
bool IsCompressed() { return signature.compr != 0; }
|
|
|
|
bool HasStrips() { return signature.face == Signature::STRIPS; }
|
|
|
|
bool HasColors() { return signature.vcolor != 0; }
|
|
|
|
bool HasNormals() { return signature.vnorm != 0; }
|
|
|
|
bool HasTextures() { return signature.vtext != 0; }
|
2004-10-15 18:45:27 +02:00
|
|
|
|
2005-01-14 16:25:29 +01:00
|
|
|
unsigned int ram_max;
|
|
|
|
unsigned int ram_used;
|
|
|
|
protected:
|
2004-10-08 16:46:26 +02:00
|
|
|
|
2005-01-14 16:25:29 +01:00
|
|
|
std::list<unsigned int> pqueue;
|
|
|
|
std::map<unsigned int, std::list<unsigned int>::iterator> index;
|
2004-10-08 16:46:26 +02:00
|
|
|
|
2005-01-14 16:25:29 +01:00
|
|
|
Patch *LoadPatch(unsigned int id);
|
|
|
|
virtual void FlushPatch(unsigned int id);
|
2004-10-08 16:46:26 +02:00
|
|
|
|
2005-01-14 16:25:29 +01:00
|
|
|
bool LoadHeader();
|
|
|
|
void SaveHeader();
|
2004-07-02 15:00:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|