Various debug

This commit is contained in:
Federico Ponchio 2004-06-25 16:47:13 +00:00
parent b4765fb09e
commit c6a58807ee
4 changed files with 96 additions and 7 deletions

View File

@ -24,6 +24,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.1 2004/06/24 14:32:45 ponchio
Moved from wrap/nexus
Revision 1.1 2004/06/22 15:31:40 ponchio
Created
@ -77,10 +80,11 @@ public:
vcg::Box3f &GetBox();
protected:
VFile<vcg::Point3f> vert;
VFile<Face> face;
protected:
FILE *fp;
unsigned int nvert;
unsigned int nface;

View File

@ -24,6 +24,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.1 2004/06/24 14:32:45 ponchio
Moved from wrap/nexus
Revision 1.2 2004/06/24 14:19:20 ponchio
Debugged
@ -37,12 +40,13 @@ Created
#define NXS_PCHAIN_H
#include <stdio.h>
#include <vector>
#include <vcg/space/point3.h>
/** Partition must be a class with a Key type, with
Levels, Locate, Priority, Save(FILE *), Load(FILE *)
as in pvoronoi.h */
namespace {
namespace nxs {
template <class Partition> class PChain {
public:

View File

@ -24,6 +24,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.1 2004/06/24 14:32:45 ponchio
Moved from wrap/nexus
Revision 1.2 2004/06/24 14:19:20 ponchio
Debugged
@ -104,14 +107,77 @@ namespace nxs {
bool Load(const std::string &file);
unsigned int Save(FILE *fp);
unsigned int Load(FILE *fp);
private:
vcg::Box3f bbox;
/** Pass iterators to Point3f container and size
to estimate optimal radius.
At the moment strategy is to campion randomly the file.
*/
template <class T>
static std::vector<float> OptimalRadii(unsigned int total,
T begin, T end,
vcg::Box3f &box,
std::vector<unsigned int> target) {
//number of samples
unsigned int n_points = 20;
std::vector<vcg::Point3f> samples;
T i;
unsigned int h;
for(i = begin, h =0; i != end; ++i, h++)
if(!((h+1)%(total/n_points)))
samples.push_back(*i);
float step = box.Diag()/10000;
//for every sample i need to record function distance -> number of points
std::vector< std::vector<int> > scale;
scale.resize(samples.size());
for(unsigned int i = 0; i < samples.size(); i++)
scale[i].resize(10001, 0);
//for every point we check distance from samples
for(i = begin; i != end; ++i) {
vcg::Point3f &vp = *i;
for(unsigned int k = 0; k < samples.size(); k++) {
float dist = (vp - samples[k]).Norm();
unsigned int pos = (int)(dist/step);
if(pos < 10000)
scale[k][pos]++;
}
}
float count =0;
unsigned int tcount = 0;
std::vector<int> counting;
for(int j = 0; j < 10000; j++) {
for(unsigned int k = 0; k < samples.size(); k++)
count += scale[k][j];
if(count > samples.size() * target[tcount]) {
counting.push_back(j);
tcount ++;
if(tcount >= target.size())
j = 10000;
}
}
std::vector<float> radius;
for(unsigned int i = 0; i < counting.size(); i++)
radius.push_back(2 * step * (counting[i]));
return radius;
}
private:
vcg::Box3f bbox;
vcg::GridStaticPtr< std::vector<Seed> > ug;
std::vector<Seed> all_seeds;
std::vector<Seed> ug_seeds;
std::vector<Seed> seedBuf;
};
}
#endif

View File

@ -24,6 +24,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.1 2004/06/24 14:32:45 ponchio
Moved from wrap/nexus
Revision 1.3 2004/06/22 15:32:09 ponchio
Tested
@ -67,15 +70,25 @@ template <class T> class VFile {
FILE *fp;
std::list<Buffer> buffers;
typedef typename std::list<Buffer>::iterator iterator;
typedef typename std::list<Buffer>::iterator list_iterator;
std::map<unsigned int, iterator> index; //TODO move to hash_map
std::map<unsigned int, list_iterator> index; //TODO move to hash_map
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 {
public:
iterator(unsigned int p = 0, VFile *b = 0): n(p), buffer(b) {}
T &operator*() { return (*buffer)[n]; }
void operator++() { n++; }
bool operator!=(const iterator &i) { return i.n != n; }
private:
unsigned int n;
VFile *buffer;
};
VFile(): fp(NULL) {}
~VFile() { if(fp) Close(); }
@ -117,7 +130,7 @@ template <class T> class VFile {
}
void Flush() {
iterator i;
list_iterator i;
for(i = buffers.begin(); i != buffers.end(); i++)
FlushBuffer(*i);
buffers.clear();
@ -201,6 +214,8 @@ template <class T> class VFile {
unsigned int Size() { return n_elements; }
unsigned int ChunkSize() { return chunk_size; }
unsigned int QueueSize() { return queue_size; }
iterator Begin() { return iterator(0, this); }
iterator End() { return iterator(Size(), this); }
protected:
void SetPosition(unsigned int chunk) {