diff --git a/apps/nexus/decimate.cpp b/apps/nexus/decimate.cpp index 01845692..8d2207a8 100644 --- a/apps/nexus/decimate.cpp +++ b/apps/nexus/decimate.cpp @@ -17,6 +17,7 @@ //#include "border.h" #include "decimate.h" +//#include using namespace vcg; using namespace tri; @@ -57,6 +58,13 @@ float nxs::Decimate(Decimation mode, vector &newface, vector &newbord, vector &vert_remap) { + + //Temporary test: + for(unsigned int i = 0; i < newface.size(); i+= 3) { + assert(newface[i*3] != newface[i*3+1]); + assert(newface[i*3] != newface[i*3+2]); + assert(newface[i*3+1] != newface[i*3+2]); + } MyMesh mesh; @@ -89,6 +97,9 @@ float nxs::Decimate(Decimation mode, // if(FinalSize > target_faces) FinalSize = target_faces; + /* if(target_faces == 2404) { + vcg::tri::io::ExporterPLY::Save(mesh, "bum"); + }*/ printf("mesh loaded %d %d \n",mesh.vn,mesh.fn); printf("reducing it to %i\n", target_faces); @@ -158,6 +169,14 @@ float nxs::Decimate(Decimation mode, assert(vert_remap[v] != -1); v = vert_remap[v]; } + + //Temporary test again: + for(unsigned int i = 0; i < newface.size(); i+= 3) { + assert(newface[i*3] != newface[i*3+1]); + assert(newface[i*3] != newface[i*3+2]); + assert(newface[i*3+1] != newface[i*3+2]); + } + return error; } diff --git a/apps/nexus/file.cpp b/apps/nexus/file.cpp new file mode 100644 index 00000000..6d890fa3 --- /dev/null +++ b/apps/nexus/file.cpp @@ -0,0 +1,112 @@ +#include "file.h" +#include + +using namespace std; +using namespace nxs; + +bool File::Create(const string &filename) { + size = 0; +#ifdef WIN32 + fp = CreateFile(filename.c_str(), GENERIC_READ | GENERIC_WRITE, 0, + NULL, CREATE_ALWAYS, 0, NULL); + if(fp == INVALID_HANDLE_VALUE) return false; +#else + fp = fopen(filename.c_str(), "wb+"); + if(!fp) return false; +#endif + return true; +} + +bool File::Load(const string &filename) { +#ifdef WIN32 + fp = CreateFile(filename.c_str(), GENERIC_READ | GENERIC_WRITE, + 0, NULL, OPEN_EXISTING, 0, NULL); + if(fp == INVALID_HANDLE_VALUE) return false; +#else + fp = fopen(filename.c_str(), "rb+"); + if(!fp) return false; +#endif + +#ifdef WIN32 + size = GetFileSize(fp, NULL); +#else + //TODO use stat() + fseek(fp, 0, SEEK_END); + size = ftell(fp); +#endif + return true; +} + +void File::Close() { + if(fp) { +#ifdef WIN32 + CloseHandle(fp); +#else + fclose(fp); +#endif + fp = NULL; + } +} + +void File::Resize(unsigned int elem) { + assert(fp); + if(elem > size) { + +#ifdef WIN32 + if(INVALID_SET_FILE_POINTER == + SetFilePointer(fp, elem - 1, 0, FILE_BEGIN)) +#else + if(-1 == fseek(fp, elem - 1, SEEK_SET)) +#endif + assert(0 && "Could not resize"); + + unsigned char a; +#ifdef WIN32 + DWORD tmp; + WriteFile(fp, &a, 1, &tmp, NULL); +#else + fwrite(&a, sizeof(unsigned char), 1, fp); +#endif + } else { + //TODO optimize: we do not need flush for buffers over elem. +#ifndef WIN32 + int fd = fileno(fp); + ftruncate(fd, elem); +#else + SetFilePointer(fp, elem, 0, FILE_BEGIN); + SetEndOfFile(fp); +#endif + } + size = elem; +} + +void File::SetPosition(unsigned int pos) { +#ifdef WIN32 + SetFilePointer(fp, pos, 0, FILE_BEGIN); +#else + fseek(fp, pos, SEEK_SET); +#endif +} + +void File::ReadBuffer(void *data, unsigned int sz) { +#ifdef WIN32 + DWORD tmp; + ReadFile(fp, data, sz, &tmp, NULL); + if(tmp != sz) + assert(0 && "Could not read"); +#else + if(sz != fread(data, 1, sz, fp)) + assert(0 && "Could not read"); +#endif +} + +void File::WriteBuffer(void *data, unsigned int sz) { +#ifdef WIN32 + DWORD tmp; + WriteFile(fp, data, sz, &tmp, NULL); + assert(tmp == sz); +#else + if(sz != fwrite(data, 1, sz, fp)) + assert(0 && "Could not write"); +#endif +} diff --git a/apps/nexus/file.h b/apps/nexus/file.h new file mode 100644 index 00000000..210cc3cd --- /dev/null +++ b/apps/nexus/file.h @@ -0,0 +1,45 @@ +#ifndef NXS_FILE_H +#define NXS_FILE_H + +//TODO move includes in cpp + +#ifdef WIN32 +#include +#else +#include +#endif + +#include +#include + +namespace nxs { + +class File { + public: + + File(): fp(NULL) {} + ~File() { Close(); } + + bool Create(const std::string &filename); + bool Load(const std::string &filename); + void Close(); + + void Resize(unsigned int elem); + + void SetPosition(unsigned int chunk); + void ReadBuffer(void *data, unsigned int size); + void WriteBuffer(void *data, unsigned int size); + + protected: + +#ifdef WIN32 + HANDLE fp; +#else + FILE *fp; +#endif + unsigned int size; +}; + +} + +#endif diff --git a/apps/nexus/nexus.cpp b/apps/nexus/nexus.cpp index 87df6ff2..5b33ffb0 100644 --- a/apps/nexus/nexus.cpp +++ b/apps/nexus/nexus.cpp @@ -126,7 +126,7 @@ void Nexus::Close() { Patch Nexus::GetPatch(unsigned int patch, bool flush) { Entry &entry = index[patch]; - Chunk *start = patches.GetRegion(entry.patch_start, entry.patch_size,flush); + Chunk *start = patches.GetRegion(entry.patch_start, entry.patch_used,flush); return Patch(signature, start, entry.nvert, entry.nface); } @@ -142,6 +142,7 @@ unsigned int Nexus::AddPatch(unsigned int nvert, unsigned int nface, Entry entry; entry.patch_start = patches.Size(); entry.patch_size = Patch::ChunkSize(signature, nvert, nface); + entry.patch_used = entry.patch_size; entry.border_start = borders.Size(); entry.border_size = nbord; entry.border_used = 0; @@ -236,6 +237,13 @@ void Nexus::Join(const std::set &patches, for(int k = 0; k < 3; k++) { newface[3*fcount + k] = vmap[patch.Face(i)[k]]; } + assert(patch.Face(i)[0] != patch.Face(i)[1]); + assert(patch.Face(i)[0] != patch.Face(i)[2]); + assert(patch.Face(i)[1] != patch.Face(i)[2]); + assert(newface[3*fcount + 0] != newface[3*fcount + 1]); + assert(newface[3*fcount + 0] != newface[3*fcount + 2]); + assert(newface[3*fcount + 1] != newface[3*fcount + 2]); + fcount++; assert(fcount *3 <= newface.size()); } diff --git a/apps/nexus/nexus.h b/apps/nexus/nexus.h index 63afd7bf..0b1c9510 100644 --- a/apps/nexus/nexus.h +++ b/apps/nexus/nexus.h @@ -24,7 +24,8 @@ class Nexus { unsigned int patch_start; //granularita' Chunk unsigned int border_start; //granuralita' Link - unsigned short patch_size; //in cuhnks + unsigned short patch_size; //in chunks + unsigned short patch_used; // in chunks (if compressed is < patch_size) unsigned short border_size; //in Links unsigned short border_used; //in Links diff --git a/apps/nexus/nexusmt.cpp b/apps/nexus/nexusmt.cpp index b5227fd6..03bbdbbc 100644 --- a/apps/nexus/nexusmt.cpp +++ b/apps/nexus/nexusmt.cpp @@ -33,12 +33,18 @@ bool FrustumPolicy::Expand(unsigned int patch, Nexus::Entry &entry) { } -NexusMt::NexusMt(): vbo(VBO_AUTO), vbo_size(0), +NexusMt::NexusMt(): vbo(VBO_AUTO), vbo_size(0), ram_size(128000000), policy(NULL), error(4), realtime(true), mode(SMOOTH) { policy = new FrustumPolicy(); } +NexusMt::~NexusMt() { + for(unsigned int i = 0; i < ram_buffer.size(); i++) + if(ram_buffer[i].patch) + delete ram_buffer[i].patch; +} + bool NexusMt::Load(const string &filename) { if(!Nexus::Load(filename)) return false; LoadHistory(); @@ -53,6 +59,9 @@ bool NexusMt::Load(const string &filename) { SetComponent(TEXTURE, true); SetComponent(DATA, true); + frame = 0; + ram_used = 0; + ram_buffer.resize(index.size()); return true; } @@ -88,10 +97,11 @@ void NexusMt::Render() { Nexus::Entry &entry = index[cell]; //frustum culling - // if(frustum.Outside(entry.sphere.center, entry.sphere.radius)) - // continue; + if(frustum.IsOutside(entry.sphere.Center(), entry.sphere.Radius())) + continue; + + Patch &patch = LoadPatch(cell); - Patch patch = GetPatch(cell); glVertexPointer(3, GL_FLOAT, 0, patch.VertBegin()); if(use_colors) glColorPointer(4, GL_UNSIGNED_BYTE, 0, patch.ColorBegin()); @@ -138,11 +148,13 @@ void NexusMt::SetPolicy(PolicyKind kind, float _error, bool _realtime) { realtime = _realtime; } -void NexusMt::SetVbo(Vbo _vbo, unsigned int _vbo_size) { +void NexusMt::SetVbo(Vbo _vbo, unsigned int _vbo_size, + unsigned int _ram_size) { vbo = _vbo; if(!GLEW_ARB_vertex_buffer_object) vbo = VBO_OFF; vbo_size = _vbo_size; + ram_size = _ram_size; } bool NexusMt::SetMode(Mode _mode) { @@ -331,3 +343,29 @@ void NexusMt::Select(vector &selected) { } } } + +Patch &NexusMt::LoadPatch(unsigned int p) { + Sgurz &sgurz = ram_buffer[p]; + if(sgurz.patch) { + sgurz.last_frame = frame; + return *(sgurz.patch); + } + + Entry &entry = index[p]; + Chunk *start = new Chunk[entry.patch_size]; + ram_used += entry.patch_size * sizeof(Chunk); + patches.SetPosition(entry.patch_start * sizeof(Chunk)); + patches.ReadBuffer(start, entry.patch_used * sizeof(Chunk)); + Patch *patch = new Patch(signature, start, entry.nvert, entry.nface); + sgurz.patch = patch; + + if(ram_used > ram_size * 1.5) + FlushRam(); + + cerr << "Ram: " << ram_used << endl; + return *(sgurz.patch); +} + +void NexusMt::FlushRam() { + //use drame info and error to prune +} diff --git a/apps/nexus/nexusmt.h b/apps/nexus/nexusmt.h index 638b9895..6ab6e443 100644 --- a/apps/nexus/nexusmt.h +++ b/apps/nexus/nexusmt.h @@ -67,6 +67,7 @@ class NexusMt: public Nexus { Vbo vbo; unsigned int vbo_size; + unsigned int ram_size; Policy *policy; float error; @@ -81,6 +82,7 @@ class NexusMt: public Nexus { bool use_data; NexusMt(); + ~NexusMt(); bool Load(const std::string &filename); bool InitGL(); @@ -88,7 +90,8 @@ class NexusMt: public Nexus { void Render(); void SetPolicy(Policy *policy, bool realtime = true); void SetPolicy(PolicyKind kind, float error, bool realtime = true); - void SetVbo(Vbo mode, unsigned int vbo_size = 0); + void SetVbo(Vbo mode, unsigned int vbo_size = 0, + unsigned int ram_size = 128000000); bool SetMode(Mode mode); bool SetComponent(Component c, bool on); bool SetComponents(unsigned int mask); @@ -100,6 +103,23 @@ class NexusMt: public Nexus { void LoadHistory(); void ClearHistory(); void Select(std::vector &selected); + Patch &LoadPatch(unsigned int p); + void FlushRam(); + + unsigned int frame; + unsigned int ram_used; + + struct Sgurz { + Sgurz(Patch *_patch = NULL, unsigned int _vbo = 0, + unsigned int _vio = 0, unsigned int _last_frame = 0): + patch(_patch), vbo(_vbo), vio(_vio), last_frame(_last_frame) {} + Patch *patch; + unsigned int vbo; //vertex buffer + unsigned int vio; //index buffer + unsigned int last_frame; + }; + + std::vector ram_buffer; }; } diff --git a/apps/nexus/nexusview.cpp b/apps/nexus/nexusview.cpp index 2785d4b2..c2ffcdc2 100644 --- a/apps/nexus/nexusview.cpp +++ b/apps/nexus/nexusview.cpp @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.10 2004/10/01 16:54:57 ponchio +Daily backup. + Revision 1.9 2004/09/30 23:56:33 ponchio Backup (added strips and normals) @@ -199,6 +202,9 @@ int main(int argc, char *argv[]) { case SDL_QUIT: quit = 1; break; case SDL_KEYDOWN: switch(event.key.keysym.sym) { + case SDLK_RCTRL: + case SDLK_LCTRL: + track.ButtonDown(Trackball::KEY_CTRL); break; case SDLK_q: exit(0); break; case SDLK_b: show_borders = !show_borders; break; case SDLK_c: show_colors = !show_colors; break; @@ -220,20 +226,32 @@ int main(int argc, char *argv[]) { cerr << "error: " << error << endl; break; } break; - case SDL_MOUSEBUTTONDOWN: + case SDL_KEYUP: + switch(event.key.keysym.sym) { + case SDLK_RCTRL: + case SDLK_LCTRL: + track.ButtonUp(Trackball::KEY_CTRL); break; + } + break; + case SDL_MOUSEBUTTONDOWN: x = event.button.x; y = height - event.button.y; - if(event.button.button == SDL_BUTTON_WHEELUP) { + if(event.button.button == SDL_BUTTON_WHEELUP) track.MouseWheel(1); - } else if(event.button.button == SDL_BUTTON_WHEELDOWN) { + else if(event.button.button == SDL_BUTTON_WHEELDOWN) track.MouseWheel(-1); - } else - track.MouseDown(x, y, 1); + else if(event.button.button == SDL_BUTTON_LEFT) + track.MouseDown(x, y, Trackball::BUTTON_LEFT); + else if(event.button.button == SDL_BUTTON_RIGHT) + track.MouseDown(x, y, Trackball::BUTTON_RIGHT); break; case SDL_MOUSEBUTTONUP: x = event.button.x; - y = height - event.button.y; - track.MouseUp(x, y, 1); + y = height - event.button.y; + if(event.button.button == SDL_BUTTON_LEFT) + track.MouseUp(x, y, Trackball::BUTTON_LEFT); + else if(event.button.button == SDL_BUTTON_RIGHT) + track.MouseUp(x, y, Trackball::BUTTON_RIGHT); break; case SDL_MOUSEMOTION: while(SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_MOUSEMOTIONMASK)); @@ -276,7 +294,10 @@ int main(int argc, char *argv[]) { Point3f center = sphere.Center(); glTranslatef(-center[0], -center[1], -center[2]); - glColor3f(0.9, 0.9, 0.9); + Point3f &p = nexus.sphere.Center(); + float r = nexus.sphere.Radius(); + + glColor3f(0.8, 0.8, 0.8); nexus.SetMode(mode); nexus.SetPolicy(policy, error); nexus.SetComponent(NexusMt::COLOR, show_colors); diff --git a/apps/nexus/nxsbuild.cpp b/apps/nexus/nxsbuild.cpp index bc5d06d8..a8a0c3c2 100644 --- a/apps/nexus/nxsbuild.cpp +++ b/apps/nexus/nxsbuild.cpp @@ -45,7 +45,7 @@ void nxs::NexusAllocate(Crude &crude, entry.patch_start = totchunks; entry.patch_size = Patch::ChunkSize(nexus.signature, patch_verts[i], patch_faces[i]); - + entry.patch_used = entry.patch_size; totchunks += entry.patch_size; entry.border_start = 0xffffffff; entry.nvert = patch_verts[i]; @@ -69,6 +69,12 @@ void nxs::NexusAllocate(Crude &crude, Patch patch = nexus.GetPatch(npatch); Crude::Face *faces = (Crude::Face *)patch.start; + + //REMOVING degenerate faces + if(face[0] == face[1] || face[1] == face[2] || face[0] == face[2]) { + cerr << "Found degenerate.\n"; + continue; + } faces[entry.nface] = face; entry.nface++; } @@ -92,6 +98,7 @@ void nxs::NexusFill(Crude &crude, //make a copy of faces (we need to write there :P) Crude::Face *faces = new Crude::Face[patch.nf]; + //Test for degenerate faces? memcpy(faces, (Crude::Face *)patch.start, patch.nf * sizeof(Crude::Face)); @@ -112,6 +119,10 @@ void nxs::NexusFill(Crude &crude, } patch.FaceBegin()[k*3 + j] = remap[face[j]]; } + //test for degenerate faces. + assert(patch.FaceBegin()[k*3] != patch.FaceBegin()[k*3+1]); + assert(patch.FaceBegin()[k*3] != patch.FaceBegin()[k*3+2]); + assert(patch.FaceBegin()[k*3+1] != patch.FaceBegin()[k*3+2]); } assert(count == remap.size()); assert(entry.nvert == remap.size()); diff --git a/apps/nexus/ply2crude.cpp b/apps/nexus/ply2crude.cpp index 40879e18..ef6e71a2 100644 --- a/apps/nexus/ply2crude.cpp +++ b/apps/nexus/ply2crude.cpp @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.3 2004/07/15 14:32:49 ponchio +Debug. + Revision 1.2 2004/07/05 15:49:39 ponchio Windows (DevCpp, mingw) port. @@ -78,7 +81,8 @@ int main(int argc, char *argv[]) { } string output = argv[argc-1]; //test last one is not a ply - if(output.substr(output.size()-4, output.size()) == ".ply") { + if(output.size() > 4 && + output.substr(output.size()-4, output.size()) == ".ply") { cerr << "Last argument is output (so not a .ply)\n"; return -1; } diff --git a/apps/nexus/vfile.h b/apps/nexus/vfile.h index 061ee9af..f652b7e3 100644 --- a/apps/nexus/vfile.h +++ b/apps/nexus/vfile.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.11 2004/10/01 16:00:12 ponchio +Added include + Revision 1.10 2004/09/30 23:56:33 ponchio Backup (added strips and normals) @@ -69,15 +72,9 @@ Created #ifndef VFILE_H #define VFILE_H -#ifndef WIN32 -#include -#else -#include -#endif +#include "file.h" #include -#include -//#include #include #include #include @@ -91,7 +88,7 @@ Created namespace nxs { -template class VFile { +template class VFile: public File { public: struct Buffer { @@ -100,13 +97,8 @@ template class VFile { T *data; }; - private: -#ifdef WIN32 - HANDLE fp; -#else - FILE *fp; -#endif - + protected: + unsigned int n_elements; std::list buffers; typedef typename std::list::iterator list_iterator; @@ -115,7 +107,6 @@ template class VFile { unsigned int chunk_size; //default buffer size (expressed in number of T) unsigned int queue_size; - unsigned int n_elements; //size of the vector public: class iterator { @@ -129,29 +120,19 @@ template class VFile { VFile *buffer; }; - VFile(): fp(NULL), last_buffer(NULL) {} - ~VFile() { Close(); } + VFile(): last_buffer(NULL) {} + ~VFile() { Close(); } bool Create(const std::string &filename, unsigned int _chunk_size = 4096/sizeof(T), unsigned int _queue_size = 1000) { assert(_chunk_size > 0); + n_elements = 0; last_buffer = NULL; chunk_size = _chunk_size; queue_size = _queue_size; - n_elements = 0; -#ifdef WIN32 - fp = CreateFile(filename.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, - 0, NULL); - if(fp == INVALID_HANDLE_VALUE) return false; -#else - fp = fopen(filename.c_str(), "wb+"); - if(!fp) return false; -#endif - - - return true; + return File::Create(filename); } bool Load(const std:: string &filename, @@ -162,35 +143,14 @@ template class VFile { last_buffer = NULL; chunk_size = _chunk_size; queue_size = _queue_size; -#ifdef WIN32 - fp = CreateFile(filename.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, - 0, NULL); - if(fp == INVALID_HANDLE_VALUE) return false; -#else - fp = fopen(filename.c_str(), "rb+"); - if(!fp) return false; -#endif - -#ifdef WIN32 - n_elements = GetFileSize(fp, NULL)/ sizeof(T); -#else - fseek(fp, 0, SEEK_END); - n_elements = ftell(fp)/ sizeof(T); -#endif + if(!File::Load(filename)) return false; + n_elements = size/sizeof(T); return true; } void Close() { - if(fp) { Flush(); -#ifdef WIN32 - CloseHandle(fp); -#else - fclose(fp); -#endif - fp = NULL; - } } void Flush() { @@ -203,51 +163,14 @@ template class VFile { } void FlushBuffer(Buffer buffer) { - SetPosition(buffer.key); - WriteBuffer(buffer.data, buffer.size); -/*#ifdef WIN32 - SetFilePointer(fp, buffer.key * chunk_size * sizeof(T), FILE_BEGIN); - unsigned int tmp; - WriteFile(fp, buffer.data, sizeof(T) * buffer.size, &tmp, NULL); - if(tmp != sizeof(T) * buffer.size) - assert(0 && "Could not write"); -#else - fseek(fp, buffer.key * chunk_size * sizeof(T), SEEK_SET); - if(buffer.size != fwrite(buffer.data, sizeof(T), buffer.size, fp)) - assert(0 && "Could not write"); -#endif*/ + SetPosition(buffer.key * chunk_size * sizeof(T)); + WriteBuffer((char *)(buffer.data), buffer.size * sizeof(T)); delete []buffer.data; } void Resize(unsigned int elem) { - assert(fp); Flush(); - if(elem > n_elements) { -#ifdef WIN32 - if(INVALID_SET_FILE_POINTER == SetFilePointer(fp, elem*sizeof(T)-1, 0, FILE_BEGIN)) -#else - if(-1 == fseek(fp, elem*sizeof(T) -1, SEEK_SET)) -#endif - assert(0 && "Could not resize"); - - unsigned char a; -#ifdef WIN32 - DWORD tmp; - WriteFile(fp, &a, 1, &tmp, NULL); -#else - fwrite(&a, sizeof(unsigned char), 1, fp); -#endif - } else { - //TODO optimize: we do not need flush for buffers over elem. - -#ifndef WIN32 - int fd = fileno(fp); - ftruncate(fd, elem*sizeof(T)); -#else - SetFilePointer(fp, elem*sizeof(T), 0, FILE_BEGIN); - SetEndOfFile(fp); -#endif - } + File::Resize(elem * sizeof(T)); n_elements = elem; } @@ -291,8 +214,8 @@ template class VFile { index[buffer.key] = buffers.begin(); last_buffer = &*buffers.begin(); - SetPosition(chunk); - ReadBuffer(buffer.data, buffer.size); + SetPosition(chunk * chunk_size * sizeof(T)); + ReadBuffer((char *)(buffer.data), buffer.size * sizeof(T)); return *(buffer.data + offset); } @@ -327,8 +250,8 @@ template class VFile { buffers.push_front(buffer); index[chunk] = buffers.begin(); - SetPosition(chunk); - ReadBuffer(buffer.data, buffer.size); + SetPosition(chunk * chunk_size * sizeof(T)); + ReadBuffer((char *)(buffer.data), buffer.size * sizeof(T)); return buffer.data; } @@ -342,37 +265,6 @@ template class VFile { unsigned int QueueSize() { return queue_size; } iterator Begin() { return iterator(0, this); } iterator End() { return iterator(Size(), this); } - - protected: - void SetPosition(unsigned int chunk) { -#ifdef WIN32 - SetFilePointer(fp, chunk * chunk_size * sizeof(T), 0, FILE_BEGIN); -#else - fseek(fp, chunk * chunk_size * sizeof(T), SEEK_SET); -#endif - } - void ReadBuffer(T *data, unsigned int size) { -#ifdef WIN32 - DWORD tmp; - ReadFile(fp, data, sizeof(T) * size, &tmp, NULL); - if(tmp != sizeof(T) * size) - assert(0 && "Could not read"); -#else - if(size != fread(data, sizeof(T), size, fp)) - assert(0 && "Could not read"); -#endif - } - void WriteBuffer(T *data, unsigned int size) { -#ifdef WIN32 - DWORD tmp; - WriteFile(fp, data, sizeof(T) * size, &tmp, NULL); - if(tmp != sizeof(T) * size) - assert(0 && "Could not write"); -#else - if(size != fwrite(data, sizeof(T), size, fp)) - assert(0 && "Could not write"); -#endif - } }; }//namespace diff --git a/apps/nexus/voronoichain.cpp b/apps/nexus/voronoichain.cpp index 8844f6d2..ad8dbff5 100644 --- a/apps/nexus/voronoichain.cpp +++ b/apps/nexus/voronoichain.cpp @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.7 2004/10/01 16:54:57 ponchio +Daily backup. + Revision 1.6 2004/09/30 00:27:42 ponchio Lot of changes. Backup. @@ -238,6 +241,7 @@ unsigned int VoronoiChain::Locate(unsigned int level, return fine + coarse * levels[level].size();*/ } +//TODO move this to nxsbuild void VoronoiChain::RemapFaces(Crude &crude, VFile &face_remap, vector &patch_faces, float scaling, int steps) { @@ -267,10 +271,7 @@ void VoronoiChain::RemapFaces(Crude &crude, VFile &face_r } else patch = patches[make_pair(coarse, fine)]; - //BEWARE unkomment this! face_remap[i] = patch; - //face_remap[i] = fine; - // face_remap[i] = coarse; if(patch_faces.size() <= patch) patch_faces.resize(patch+1, 0); patch_faces[patch]++; diff --git a/apps/nexus/voronoinxs.cpp b/apps/nexus/voronoinxs.cpp index 3aa01263..0f01cda1 100644 --- a/apps/nexus/voronoinxs.cpp +++ b/apps/nexus/voronoinxs.cpp @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.6 2004/10/01 16:54:57 ponchio +Daily backup. + Revision 1.5 2004/09/30 00:27:42 ponchio Lot of changes. Backup. @@ -161,7 +164,8 @@ int main(int argc, char *argv[]) { cerr << " -f N: use N faces per patch (default 1000, max 32000)\n"; cerr << " -t N: mini faces per patch (default 200)\n"; cerr << " -l N: number of levels\n"; - cerr << " -s F: scaling factor (0 < F < 1, default 0.5)\n\n"; + cerr << " -s F: scaling factor (0 < F < 1, default 0.5)\n"; + cerr << " -o N: nomber of optimization steps\n"; cerr << " -d : decimation method: quadric, cluster. (default quadric)\n"; return -1; }