Windows (DevCpp, mingw) port.
This commit is contained in:
parent
e7e9d70390
commit
3ca1082ace
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.3 2004/07/04 15:25:33 ponchio
|
||||
Backup (work in progress)
|
||||
|
||||
Revision 1.2 2004/06/25 16:47:13 ponchio
|
||||
Various debug
|
||||
|
||||
|
@ -86,7 +89,7 @@ public:
|
|||
|
||||
vcg::Box3f &GetBox();
|
||||
|
||||
template <class MESH> void Export(MESH &mesh) {
|
||||
/*template <class MESH> void Export(MESH &mesh) {
|
||||
MESH::VertexType v;
|
||||
v.ClearFlags();
|
||||
for(unsigned int i = 0; i < <Vertices(); i++) {
|
||||
|
@ -102,7 +105,7 @@ public:
|
|||
mesh.vert.push_back(GetVertex(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
protected:
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.1 2004/07/04 15:30:00 ponchio
|
||||
Changed directory structure.
|
||||
|
||||
Revision 1.3 2004/07/04 14:28:05 ponchio
|
||||
Finito e debuggato
|
||||
|
||||
|
@ -40,10 +43,10 @@ Created
|
|||
#include <set> //DEBUG
|
||||
#include <map>
|
||||
|
||||
#include "../nexus.h"
|
||||
#include "../crude.h"
|
||||
#include "../vert_remap.h"
|
||||
#include "../vfile.h"
|
||||
#include "nexus.h"
|
||||
#include "crude.h"
|
||||
#include "vert_remap.h"
|
||||
#include "vfile.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace vcg;
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.1 2004/07/04 15:30:00 ponchio
|
||||
Changed directory structure.
|
||||
|
||||
Revision 1.3 2004/07/02 13:03:34 ponchio
|
||||
*** empty log message ***
|
||||
|
||||
|
@ -41,6 +44,10 @@ using namespace std;
|
|||
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
|
@ -96,8 +103,8 @@ bool init() {
|
|||
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char file[64];
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
if(argc < 2) {
|
||||
cerr << "Usage: " << argv[0] << " <crude file>\n";
|
||||
return -1;
|
||||
|
@ -112,16 +119,21 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
bool vremap = false;
|
||||
bool fremap = false;
|
||||
|
||||
VFile<unsigned int> face_remap;
|
||||
if(face_remap.Load(argv[1] + string(".rmf"))) {
|
||||
cerr << "Found face remap.\n";
|
||||
fremap = true;
|
||||
} else {
|
||||
cerr << "Face remap not found.\n";
|
||||
}
|
||||
|
||||
VertRemap vert_remap;
|
||||
if(vert_remap.Load(argv[1])) {
|
||||
cerr << "Found vert remap.\n";
|
||||
vremap = true;
|
||||
}
|
||||
VFile<unsigned int> face_remap;
|
||||
if(face_remap.Load(argv[1] + string(".rmf"))) {
|
||||
cerr << "Found face remap.\n";
|
||||
fremap = true;
|
||||
}
|
||||
|
||||
|
||||
if(!init()) {
|
||||
cerr << "Could not init SDL window\n";
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.4 2004/07/04 14:23:14 ponchio
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.3 2004/07/02 17:40:30 ponchio
|
||||
Debug.
|
||||
|
||||
|
@ -39,8 +42,10 @@ Created
|
|||
|
||||
****************************************************************************/
|
||||
|
||||
#include "mfhash.h"
|
||||
#include <assert.h>
|
||||
#include <iostream>
|
||||
#include "mfhash.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace nxs;
|
||||
|
|
|
@ -112,9 +112,9 @@ unsigned int Nexus::AddPatch(unsigned int nvert, unsigned int nface,
|
|||
}
|
||||
|
||||
void Nexus::Join(std::vector<unsigned int> &patches,
|
||||
std::vector<Point3f &newvert,
|
||||
std::vector<Point3f> &newvert,
|
||||
std::vector<unsigned int> &newface,
|
||||
std::vector<Link> &newlinks) {
|
||||
std::vector<Link> &newbord) {
|
||||
|
||||
map<unsigned int, vector<unsigned int> > remap;
|
||||
|
||||
|
@ -181,7 +181,7 @@ void Nexus::Join(std::vector<unsigned int> &patches,
|
|||
newbord[bcount++] = newlink;
|
||||
}
|
||||
}
|
||||
unsigned int newentry = AddPatch(vcount, fcount, bcount);
|
||||
/* unsigned int newentry = AddPatch(vcount, fcount, bcount);
|
||||
Patch newpatch = GetPatch(newentry);
|
||||
Border newborder = GetBorder(newentry);
|
||||
|
||||
|
@ -192,6 +192,6 @@ void Nexus::Join(std::vector<unsigned int> &patches,
|
|||
newface.size() * sizeof(unsigned short));
|
||||
|
||||
memcpy(&(newborder[0]), &(newbord[0]),
|
||||
newbord.size() * sizeof(Link));
|
||||
return newentry;
|
||||
newbord.size() * sizeof(Link));*/
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <vcg/space/point3.h>
|
||||
#include <vcg/space/sphere3.h>
|
||||
#include "vfile.h"
|
||||
#include "patch.h"
|
||||
|
@ -44,7 +45,7 @@ class Nexus {
|
|||
|
||||
// unsigned int Join(std::vector<unsigned int> &patches);
|
||||
void Join(std::vector<unsigned int> &patches,
|
||||
std::vector<Point3f &vert,
|
||||
std::vector<vcg::Point3f> &vert,
|
||||
std::vector<unsigned int> &faces,
|
||||
std::vector<Link> &links);
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.1 2004/07/04 15:30:00 ponchio
|
||||
Changed directory structure.
|
||||
|
||||
Revision 1.2 2004/07/04 15:16:01 ponchio
|
||||
*** empty log message ***
|
||||
|
||||
|
@ -180,7 +183,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
|
||||
|
||||
for(unsigned int i = 7; i < nexus.index.size(); i++) {
|
||||
for(unsigned int i = 0; i < nexus.index.size(); i++) {
|
||||
Patch patch = nexus.GetPatch(i);
|
||||
|
||||
unsigned int val = i + 1;
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.1 2004/07/04 15:30:00 ponchio
|
||||
Changed directory structure.
|
||||
|
||||
Revision 1.2 2004/07/02 13:09:57 ponchio
|
||||
*** empty log message ***
|
||||
|
||||
|
@ -38,7 +41,7 @@ Created
|
|||
#include <string>
|
||||
#include <iostream>
|
||||
#include <wrap/ply/plylib.h>
|
||||
#include "../crude.h"
|
||||
#include "crude.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace vcg;
|
||||
|
@ -65,7 +68,7 @@ PropDescriptor plyprop2[1]= {
|
|||
1,0,T_UCHAR,T_UCHAR,offsetof(PlyFace,flags) }
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int argc, char *argv[]) {
|
||||
if(argc <= 2) {
|
||||
cerr << "Usage: " << argv[0] << " <input1.ply> <...> <inputN.ply> <output>\n";
|
||||
return 0;
|
||||
|
|
|
@ -24,13 +24,16 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.1 2004/07/01 21:38:30 ponchio
|
||||
First draft created.
|
||||
|
||||
|
||||
****************************************************************************/
|
||||
#include "stopwatch.h"
|
||||
|
||||
StopWatch::StopWatch(): elapsed(0) {}
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef WIN32
|
||||
void StopWatch::Start(void) {
|
||||
static int first = 1;
|
||||
if(first) {
|
||||
|
@ -78,7 +81,7 @@ double StopWatch::Elapsed() {
|
|||
}
|
||||
|
||||
int StopWatch::Usec() {
|
||||
#ifdef _WIN32
|
||||
#ifdef WIN32
|
||||
return 0;
|
||||
#else
|
||||
struct timeval ttime;
|
||||
|
|
|
@ -24,10 +24,18 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.1 2004/07/01 21:38:30 ponchio
|
||||
First draft created.
|
||||
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
class StopWatch {
|
||||
public:
|
||||
|
@ -40,9 +48,9 @@ public:
|
|||
private:
|
||||
double Diff();
|
||||
|
||||
#ifdef _WIN32
|
||||
static LARGE_INTEGER _tstart, _tend;
|
||||
static LARGE_INTEGER freq;
|
||||
#ifdef WIN32
|
||||
LARGE_INTEGER tstart, tend;
|
||||
LARGE_INTEGER freq;
|
||||
#else
|
||||
struct timeval tstart, tend;
|
||||
struct timezone tz;
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.4 2004/07/02 17:41:37 ponchio
|
||||
Debug.
|
||||
|
||||
Revision 1.3 2004/07/02 13:01:28 ponchio
|
||||
Changed file extensions to .rmv, .rmb
|
||||
|
||||
|
@ -39,6 +42,7 @@ Created
|
|||
|
||||
****************************************************************************/
|
||||
|
||||
#include <assert.h>
|
||||
#include <iostream>
|
||||
#include "vert_remap.h"
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.6 2004/07/04 15:23:48 ponchio
|
||||
Debug
|
||||
|
||||
Revision 1.5 2004/07/02 17:41:37 ponchio
|
||||
Debug.
|
||||
|
||||
|
@ -54,7 +57,12 @@ Created
|
|||
#ifndef VFILE_H
|
||||
#define VFILE_H
|
||||
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
//#include <hash_map>
|
||||
#include <map>
|
||||
|
@ -80,8 +88,12 @@ template <class T> class VFile {
|
|||
};
|
||||
|
||||
private:
|
||||
|
||||
#ifdef WIN32
|
||||
HANDLE fp;
|
||||
#else
|
||||
FILE *fp;
|
||||
#endif
|
||||
|
||||
std::list<Buffer> buffers;
|
||||
typedef typename std::list<Buffer>::iterator list_iterator;
|
||||
|
||||
|
@ -114,8 +126,15 @@ template <class T> class VFile {
|
|||
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;
|
||||
}
|
||||
|
@ -127,19 +146,33 @@ template <class T> class VFile {
|
|||
assert(_chunk_size > 0);
|
||||
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
|
||||
return true;
|
||||
}
|
||||
|
||||
void Close() {
|
||||
if(fp) {
|
||||
Flush();
|
||||
#ifdef WIN32
|
||||
CloseHandle(fp);
|
||||
#else
|
||||
fclose(fp);
|
||||
#endif
|
||||
fp = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -153,10 +186,19 @@ template <class T> 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");
|
||||
}
|
||||
if(buffer.size != fwrite(buffer.data, sizeof(T), buffer.size, fp))
|
||||
assert(0 && "Could not write");
|
||||
#endif*/
|
||||
delete []buffer.data;
|
||||
}
|
||||
|
||||
|
@ -164,15 +206,30 @@ template <class T> class VFile {
|
|||
assert(fp);
|
||||
Flush();
|
||||
if(elem > n_elements) {
|
||||
if(-1 == fseek(fp, elem*sizeof(T) -1, SEEK_SET)) {
|
||||
assert(0 && "Could not resize");
|
||||
}
|
||||
#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
|
||||
}
|
||||
n_elements = elem;
|
||||
}
|
||||
|
@ -208,20 +265,33 @@ template <class T> class VFile {
|
|||
|
||||
buffers.push_front(buffer);
|
||||
index[buffer.key] = buffers.begin();
|
||||
|
||||
SetPosition(chunk);
|
||||
ReadBuffer(buffer.data, buffer.size);
|
||||
/*#ifdef WIN32
|
||||
if(INVALID_SET_FILE_POINTER == SetFilePointer(fp, chunk * chunk_size * sizeof(T), 0, FILE_BEGIN)) {
|
||||
#else
|
||||
if(fseek(fp, chunk * chunk_size * sizeof(T), SEEK_SET)) {
|
||||
#endif
|
||||
assert(0 && "failed to fseek");
|
||||
return *(buffer.data);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
unsigned int tmp;
|
||||
tmp = ReadFile(fp, buffer.data, sizeof(T) * buffer.size, &tmp, NULL);
|
||||
if(tmp != sizeof(T) * buffer.size)
|
||||
assert(0 && "failed reading.");
|
||||
return (*buffer.data);
|
||||
#else
|
||||
if(buffer.size != fread(buffer.data, sizeof(T), buffer.size, fp)) {
|
||||
if(feof(fp)) {
|
||||
assert(0 && "end of file");
|
||||
assert(0 && "end of file");
|
||||
} else {
|
||||
assert(0 && "failed reading!");
|
||||
assert(0 && "failed reading!");
|
||||
}
|
||||
return (*buffer.data);
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
return *(buffer.data + offset);
|
||||
}
|
||||
|
@ -262,7 +332,9 @@ template <class T> class VFile {
|
|||
buffers.push_front(buffer);
|
||||
index[chunk] = buffers.begin();
|
||||
|
||||
if(fseek(fp, chunk * chunk_size * sizeof(T), SEEK_SET)) {
|
||||
SetPosition(chunk);
|
||||
ReadBuffer(buffer.data, buffer.size);
|
||||
/*if(fseek(fp, chunk * chunk_size * sizeof(T), SEEK_SET)) {
|
||||
assert(0 && "failed to fseek");
|
||||
return buffer.data;
|
||||
}
|
||||
|
@ -274,44 +346,9 @@ template <class T> class VFile {
|
|||
assert(0 && "failed reading!");
|
||||
}
|
||||
return buffer.data;
|
||||
}
|
||||
} */
|
||||
return buffer.data;
|
||||
}
|
||||
|
||||
/** Allocate copy and return (remember to delete it) memory.
|
||||
size is number of elements. **/
|
||||
T *Read(unsigned int begin, unsigned int size) {
|
||||
//to make its simple we flush and read.
|
||||
Flush();
|
||||
T *buf = new T[size];
|
||||
if(fseek(fp, begin * sizeof(T), SEEK_SET)) {
|
||||
assert(0 && "failed to fseek");
|
||||
return buf;
|
||||
}
|
||||
if(size != fread(buf, sizeof(T), size, fp)) {
|
||||
if(feof(fp)) {
|
||||
assert(0 && "end of file");
|
||||
} else {
|
||||
assert(0 && "failed reading!");
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
void Write(T *buf, unsigned int begin, unsigned int size) {
|
||||
//to make its simple we flush and read.
|
||||
Flush();
|
||||
if(fseek(fp, begin * sizeof(T), SEEK_SET)) {
|
||||
assert(0 && "failed to fseek");
|
||||
}
|
||||
if(size != fwrite(buf, sizeof(T), size, fp)) {
|
||||
if(feof(fp)) {
|
||||
assert(0 && "end of file");
|
||||
} else {
|
||||
assert(0 && "failed reading!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int Size() { return n_elements; }
|
||||
unsigned int ChunkSize() { return chunk_size; }
|
||||
|
@ -321,7 +358,33 @@ template <class T> class VFile {
|
|||
|
||||
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
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.1 2004/07/04 15:30:00 ponchio
|
||||
Changed directory structure.
|
||||
|
||||
Revision 1.3 2004/07/02 17:42:43 ponchio
|
||||
Debug.
|
||||
|
||||
|
@ -37,12 +40,12 @@ Created
|
|||
****************************************************************************/
|
||||
|
||||
#include <iostream>
|
||||
#include "../pchain.h"
|
||||
#include "../pvoronoi.h"
|
||||
#include "../vert_remap.h"
|
||||
#include "../crude.h"
|
||||
#include "../stopwatch.h"
|
||||
#include "../pintersect.h"
|
||||
#include "pchain.h"
|
||||
#include "pvoronoi.h"
|
||||
#include "vert_remap.h"
|
||||
#include "crude.h"
|
||||
#include "stopwatch.h"
|
||||
#include "pintersect.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace nxs;
|
||||
|
|
Loading…
Reference in New Issue