vcglib/apps/nexus/nexus.h

107 lines
2.2 KiB
C
Raw Normal View History

2004-07-02 15:00:02 +02:00
#ifndef NXS_NEXUS_H
#define NXS_NEXUS_H
#include <string>
#include <vector>
2004-08-27 02:38:34 +02:00
#include <set>
2004-07-05 17:49:39 +02:00
#include <vcg/space/point3.h>
2004-10-08 16:46:26 +02:00
#include "patchserver.h"
#include "borderserver.h"
2004-07-02 15:00:02 +02:00
namespace nxs {
2004-10-08 16:46:26 +02:00
struct PatchInfo {
unsigned short nvert;
unsigned short nface;
vcg::Sphere3f sphere;
float error;
};
2004-07-02 15:00:02 +02:00
class Nexus {
public:
2004-10-08 16:46:26 +02:00
struct BorderEntry {
2004-07-04 16:26:46 +02:00
unsigned int border_start; //granuralita' Link
2004-07-02 15:00:02 +02:00
unsigned short border_size; //in Links
2004-09-17 17:25:59 +02:00
unsigned short border_used; //in Links
2004-10-08 16:46:26 +02:00
};
struct PatchInfo {
2004-07-04 16:26:46 +02:00
unsigned short nvert;
unsigned short nface;
2004-10-08 16:46:26 +02:00
2004-07-02 15:00:02 +02:00
vcg::Sphere3f sphere;
2004-09-16 16:25:16 +02:00
float error;
};
2004-10-08 16:46:26 +02:00
//TODO optimize to be vector with offset.
2004-09-16 16:25:16 +02:00
struct Update {
std::vector<unsigned int> erased;
std::vector<unsigned int> created;
2004-07-02 15:00:02 +02:00
};
2004-09-16 16:25:16 +02:00
2004-07-02 15:00:02 +02:00
Nexus();
2004-09-30 02:27:42 +02:00
virtual ~Nexus();
2004-10-08 16:46:26 +02:00
2004-10-10 19:19:42 +02:00
bool Create(const std::string &filename, Signature signature,
unsigned int chunk_size = 1024);
2004-10-08 16:46:26 +02:00
virtual bool Load(const std::string &filename, bool readonly = false);
2004-09-30 02:27:42 +02:00
virtual void Close();
2004-07-02 15:00:02 +02:00
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);
2004-10-01 18:54:57 +02:00
Border GetBorder(unsigned int patch, bool flush = true);
2004-07-04 16:26:46 +02:00
2004-10-09 16:46:47 +02:00
bool IsCompressed() { return (signature & NXS_COMPRESSED) != 0; }
bool HasStrips() { return (signature & NXS_STRIP) != 0; }
bool HasColors() { return (signature & NXS_COLORS) != 0; }
bool HasNormalsShort() { return (signature & NXS_NORMALS_SHORT) != 0; }
bool HasNormalsFloat() { return (signature & NXS_NORMALS_FLOAT) != 0; }
2004-10-15 18:45:27 +02:00
void SetRamBufferSize(unsigned int ram_size);
2004-09-17 17:25:59 +02:00
//MOVE to nexus_build.cpp
2004-08-27 02:38:34 +02:00
void Join(const std::set<unsigned int> &patches,
2004-07-05 17:49:39 +02:00
std::vector<vcg::Point3f> &vert,
2004-07-04 16:26:46 +02:00
std::vector<unsigned int> &faces,
std::vector<Link> &links);
2004-07-02 15:00:02 +02:00
2004-10-08 16:46:26 +02:00
//move to nxsalgo!
2004-09-17 17:25:59 +02:00
void Unify(float threshold = 0.0f);
2004-10-08 16:46:26 +02:00
/* Nexus data */
2004-09-17 17:25:59 +02:00
2004-10-08 16:46:26 +02:00
//BE CAREFUL: this 2 members get replicated into patchserver
2004-10-10 19:19:42 +02:00
//TODO fix this nasty thing it is dangerous as it is.
2004-09-17 17:25:59 +02:00
Signature signature;
2004-10-08 16:46:26 +02:00
unsigned int chunk_size;
2004-07-02 15:00:02 +02:00
unsigned int totvert;
unsigned int totface;
vcg::Sphere3f sphere;
2004-10-08 16:46:26 +02:00
std::vector<PatchInfo> index;
2004-07-02 15:00:02 +02:00
2004-10-08 16:46:26 +02:00
PatchServer patches;
BorderServer borders;
2004-09-16 16:25:16 +02:00
std::vector<Update> history;
2004-10-08 16:46:26 +02:00
bool readonly;
2004-07-04 16:26:46 +02:00
private:
FILE *index_file;
2004-07-02 15:00:02 +02:00
};
}
#endif