debug debug debug
This commit is contained in:
parent
0a02f99ecf
commit
00d5475c81
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.9 2005/02/08 12:43:03 ponchio
|
||||||
|
Added copyright
|
||||||
|
|
||||||
|
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
@ -32,6 +35,7 @@ $Log: not supported by cvs2svn $
|
||||||
|
|
||||||
#include "fragment.h"
|
#include "fragment.h"
|
||||||
#include "border.h"
|
#include "border.h"
|
||||||
|
#include "nxsalgo.h"
|
||||||
//#include "pvoronoi.h"
|
//#include "pvoronoi.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +44,11 @@ using namespace vcg;
|
||||||
using namespace nxs;
|
using namespace nxs;
|
||||||
using namespace pt;
|
using namespace pt;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void NxsPatch::Write(outstm *out) {
|
void NxsPatch::Write(outstm *out) {
|
||||||
|
out->write(&sphere, sizeof(Sphere3f));
|
||||||
|
out->write(&cone, sizeof(ANCone3f));
|
||||||
int vsize = vert.size();
|
int vsize = vert.size();
|
||||||
int fsize = face.size();
|
int fsize = face.size();
|
||||||
int bsize = bord.size();
|
int bsize = bord.size();
|
||||||
|
@ -56,6 +64,8 @@ void NxsPatch::Write(outstm *out) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NxsPatch::Read(instm *in) {
|
void NxsPatch::Read(instm *in) {
|
||||||
|
in->read(&sphere, sizeof(Sphere3f));
|
||||||
|
in->read(&cone, sizeof(ANCone3f));
|
||||||
int vsize;
|
int vsize;
|
||||||
int fsize;
|
int fsize;
|
||||||
int bsize;
|
int bsize;
|
||||||
|
@ -385,6 +395,25 @@ void nxs::Split(Fragment &out,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//process Cone and sphere
|
||||||
|
for(unsigned int seed = 0; seed != nseeds; seed++) {
|
||||||
|
NxsPatch &patch = out.pieces[seed];
|
||||||
|
Sphere3f &sphere = patch.sphere;
|
||||||
|
sphere.CreateTight(patch.vert.size(), &*patch.vert.begin());
|
||||||
|
|
||||||
|
//NORMALS CONE
|
||||||
|
vector<Point3f> normals;
|
||||||
|
for(unsigned int i = 0; i < patch.face.size(); i += 3) {
|
||||||
|
unsigned short *f = &(patch.face[i]);
|
||||||
|
Point3f &v0 = patch.vert[f[0]];
|
||||||
|
Point3f &v1 = patch.vert[f[1]];
|
||||||
|
Point3f &v2 = patch.vert[f[2]];
|
||||||
|
|
||||||
|
Point3f norm = (v1 - v0) ^ (v2 - v0);
|
||||||
|
normals.push_back(norm.Normalize());
|
||||||
|
}
|
||||||
|
patch.cone.AddNormals(normals, 0.99f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Fragment::Locate(const Point3f &p) {
|
unsigned int Fragment::Locate(const Point3f &p) {
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.6 2005/02/08 12:43:03 ponchio
|
||||||
|
Added copyright
|
||||||
|
|
||||||
|
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
@ -59,6 +62,9 @@ class NxsPatch {
|
||||||
//this fields is the patch number in the infragment
|
//this fields is the patch number in the infragment
|
||||||
//and the seeds id in the outfragment
|
//and the seeds id in the outfragment
|
||||||
unsigned int patch;
|
unsigned int patch;
|
||||||
|
vcg::Sphere3f sphere;
|
||||||
|
ANCone3f cone;
|
||||||
|
|
||||||
std::vector<vcg::Point3f> vert;
|
std::vector<vcg::Point3f> vert;
|
||||||
std::vector<unsigned short> face;
|
std::vector<unsigned short> face;
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.21 2005/02/20 18:07:01 ponchio
|
||||||
|
cleaning.
|
||||||
|
|
||||||
Revision 1.20 2005/02/19 10:45:04 ponchio
|
Revision 1.20 2005/02/19 10:45:04 ponchio
|
||||||
Patch generalized and small fixes.
|
Patch generalized and small fixes.
|
||||||
|
|
||||||
|
@ -48,6 +51,7 @@ Added copyright
|
||||||
//#include <wrap/strip/tristrip.h>
|
//#include <wrap/strip/tristrip.h>
|
||||||
|
|
||||||
#include "nxsalgo.h"
|
#include "nxsalgo.h"
|
||||||
|
#include "vpartition.h"
|
||||||
#include "vfile.h"
|
#include "vfile.h"
|
||||||
#include "nexus.h"
|
#include "nexus.h"
|
||||||
#include "zcurve.h"
|
#include "zcurve.h"
|
||||||
|
@ -61,7 +65,7 @@ using namespace vcg;
|
||||||
using namespace triangle_stripper;
|
using namespace triangle_stripper;
|
||||||
|
|
||||||
|
|
||||||
void nxs::TightSphere(vcg::Sphere3f &sphere,
|
/*void nxs::TightSphere(vcg::Sphere3f &sphere,
|
||||||
std::vector<vcg::Point3f> &points) {
|
std::vector<vcg::Point3f> &points) {
|
||||||
//test:
|
//test:
|
||||||
//assumes radius is ok.... and try to optimize moving center.
|
//assumes radius is ok.... and try to optimize moving center.
|
||||||
|
@ -107,7 +111,7 @@ void nxs::TightSphere(vcg::Sphere3f &sphere,
|
||||||
sphere.Center() = sphere.Center() + pert[best];
|
sphere.Center() = sphere.Center() + pert[best];
|
||||||
sphere.Radius() = best_radius;
|
sphere.Radius() = best_radius;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -184,10 +188,6 @@ void nxs::ComputeNormals(Nexus &nexus) {
|
||||||
normals[f[2]] += norm;
|
normals[f[2]] += norm;
|
||||||
}
|
}
|
||||||
|
|
||||||
//compute normalscone (done in building...
|
|
||||||
// ANCone3f cone;
|
|
||||||
// cone.AddNormals(normals, cone_threshold);
|
|
||||||
// nexus[p].cone.Import(cone);
|
|
||||||
if(nexus.signature.vnorm == Encodings::SHORT4) {
|
if(nexus.signature.vnorm == Encodings::SHORT4) {
|
||||||
short *n = (short *)patch.VNormBegin();
|
short *n = (short *)patch.VNormBegin();
|
||||||
for(unsigned int i = 0; i < patch.nv; i++, n += 4) {
|
for(unsigned int i = 0; i < patch.nv; i++, n += 4) {
|
||||||
|
@ -198,8 +198,11 @@ void nxs::ComputeNormals(Nexus &nexus) {
|
||||||
n[3] = 0;
|
n[3] = 0;
|
||||||
}
|
}
|
||||||
} else if(nexus.signature.vnorm == Encodings::FLOAT3) {
|
} else if(nexus.signature.vnorm == Encodings::FLOAT3) {
|
||||||
memcpy(patch.VNormBegin(), &*normals.begin(),
|
Point3f *n = (Point3f *)patch.VNormBegin();
|
||||||
normals.size() * sizeof(Point3f));
|
for(unsigned int i = 0; i < patch.nv; i++) {
|
||||||
|
n[i] = normals[i];
|
||||||
|
n[i].Normalize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -373,6 +376,8 @@ void nxs::ComputeTriStrip(unsigned short nfaces, unsigned short *faces,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
//TODO why i created this function? wonder...
|
||||||
void nxs::Reorder(Signature &signature, Patch &patch) {
|
void nxs::Reorder(Signature &signature, Patch &patch) {
|
||||||
vector<unsigned> remap;
|
vector<unsigned> remap;
|
||||||
remap.resize(patch.nv, 0xffff);
|
remap.resize(patch.nv, 0xffff);
|
||||||
|
@ -407,10 +412,11 @@ void nxs::Reorder(Signature &signature, Patch &patch) {
|
||||||
memcpy(&*vert.begin(), patch.Vert3fBegin(), patch.nv * sizeof(Point3f));
|
memcpy(&*vert.begin(), patch.Vert3fBegin(), patch.nv * sizeof(Point3f));
|
||||||
for(int i = 0; i < patch.nv; i++)
|
for(int i = 0; i < patch.nv; i++)
|
||||||
patch.Vert3f(remap[i]) = vert[i];
|
patch.Vert3f(remap[i]) = vert[i];
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//TODO actually use threshold
|
//TODO actually use threshold
|
||||||
void nxs::Unify(Nexus &nexus, float threshold) {
|
void nxs::Unify(Nexus &nexus, float threshold) {
|
||||||
|
threshold = 0.001;
|
||||||
//TODO what if colors or normals or strips?
|
//TODO what if colors or normals or strips?
|
||||||
unsigned int duplicated = 0;
|
unsigned int duplicated = 0;
|
||||||
unsigned int degenerate = 0;
|
unsigned int degenerate = 0;
|
||||||
|
@ -419,44 +425,62 @@ void nxs::Unify(Nexus &nexus, float threshold) {
|
||||||
Entry &entry = nexus[p];
|
Entry &entry = nexus[p];
|
||||||
Patch &patch = nexus.GetPatch(p);
|
Patch &patch = nexus.GetPatch(p);
|
||||||
|
|
||||||
unsigned int vcount = 0;
|
|
||||||
map<Point3f, unsigned short> vertices;
|
|
||||||
|
|
||||||
|
|
||||||
|
VPartition part;
|
||||||
|
for(unsigned int i = 0; i < patch.nv; i++) {
|
||||||
|
Point3f &point = patch.Vert3f(i);
|
||||||
|
part.push_back(point);
|
||||||
|
}
|
||||||
|
part.Init();
|
||||||
|
|
||||||
|
unsigned int vcount = 0;
|
||||||
vector<unsigned short> remap;
|
vector<unsigned short> remap;
|
||||||
remap.resize(patch.nv);
|
remap.resize(patch.nv);
|
||||||
|
|
||||||
|
int targets[8];
|
||||||
|
double dists[8];
|
||||||
|
|
||||||
|
//TODO CRITICAL FIX this unifying routine.
|
||||||
for(unsigned int i = 0; i < patch.nv; i++) {
|
for(unsigned int i = 0; i < patch.nv; i++) {
|
||||||
Point3f &point = patch.Vert3f(i);
|
Point3f &point = patch.Vert3f(i);
|
||||||
|
part.Closest(point, 8, targets, dists);
|
||||||
|
int k = 0;
|
||||||
|
for(k = 0; k < 8; k++) {
|
||||||
|
if(dists[k] > threshold) {
|
||||||
|
remap[i] = vcount++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(targets[k] < i) {
|
||||||
|
remap[i] = remap[targets[k]];
|
||||||
|
duplicated++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(k == 8)
|
||||||
|
remap[i] = vcount++;
|
||||||
|
|
||||||
if(!vertices.count(point))
|
|
||||||
vertices[point] = vcount++;
|
|
||||||
else
|
|
||||||
duplicated++;
|
|
||||||
|
|
||||||
remap[i] = vertices[point];
|
|
||||||
}
|
}
|
||||||
assert(vertices.size() <= patch.nv);
|
|
||||||
if(vertices.size() == patch.nv) //no need to unify
|
if(vcount == patch.nv) //no need to unify
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
vector<Point3f> newvert;
|
vector<Point3f> newvert;
|
||||||
newvert.resize(vertices.size());
|
newvert.resize(vcount);
|
||||||
map<Point3f, unsigned short>::iterator k;
|
for(unsigned int i = 0; i < patch.nv; i++)
|
||||||
for(k = vertices.begin(); k != vertices.end(); k++) {
|
newvert[remap[i]] = patch.Vert3f(i);
|
||||||
newvert[(*k).second] = (*k).first;
|
|
||||||
}
|
|
||||||
|
|
||||||
vector<unsigned short> newface;
|
vector<unsigned short> newface;
|
||||||
//check no degenerate faces get created.
|
//check no degenerate faces get created.
|
||||||
for(unsigned int f = 0; f < entry.nface; f++) {
|
for(unsigned int f = 0; f < entry.nface; f++) {
|
||||||
unsigned short *face = patch.Face(f);
|
unsigned short *face = patch.Face(f);
|
||||||
if(face[0] != face[1] && face[1] != face[2] && face[0] != face[2] &&
|
if(face[0] != face[1] && face[1] != face[2] && face[0] != face[2] &&
|
||||||
newvert[remap[face[0]]] != newvert[remap[face[1]]] &&
|
newvert[remap[face[0]]] != newvert[remap[face[1]]] &&
|
||||||
newvert[remap[face[0]]] != newvert[remap[face[2]]] &&
|
newvert[remap[face[0]]] != newvert[remap[face[2]]] &&
|
||||||
newvert[remap[face[1]]] != newvert[remap[face[2]]]) {
|
newvert[remap[face[1]]] != newvert[remap[face[2]]]) {
|
||||||
newface.push_back(remap[face[0]]);
|
newface.push_back(remap[face[0]]);
|
||||||
newface.push_back(remap[face[1]]);
|
newface.push_back(remap[face[1]]);
|
||||||
newface.push_back(remap[face[2]]);
|
newface.push_back(remap[face[2]]);
|
||||||
} else {
|
} else {
|
||||||
degenerate++;
|
degenerate++;
|
||||||
}
|
}
|
||||||
|
@ -471,6 +495,7 @@ void nxs::Unify(Nexus &nexus, float threshold) {
|
||||||
memcpy(patch.FaceBegin(), &(newface[0]), entry.nface*3*sizeof(short));
|
memcpy(patch.FaceBegin(), &(newface[0]), entry.nface*3*sizeof(short));
|
||||||
|
|
||||||
//testiamo il tutto... TODO remove this of course
|
//testiamo il tutto... TODO remove this of course
|
||||||
|
#ifdef NDEBUG
|
||||||
for(unsigned int i =0; i < patch.nf; i++) {
|
for(unsigned int i =0; i < patch.nf; i++) {
|
||||||
for(int k =0 ; k < 3; k++)
|
for(int k =0 ; k < 3; k++)
|
||||||
if(patch.Face(i)[k] >= patch.nv) {
|
if(patch.Face(i)[k] >= patch.nv) {
|
||||||
|
@ -478,6 +503,8 @@ void nxs::Unify(Nexus &nexus, float threshold) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
//TODO CRITICAL FIX unify vertices across borders..... HOW??????
|
||||||
|
|
||||||
//fix patch borders now
|
//fix patch borders now
|
||||||
set<unsigned int> close; //bordering pathes
|
set<unsigned int> close; //bordering pathes
|
||||||
|
@ -500,6 +527,7 @@ void nxs::Unify(Nexus &nexus, float threshold) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//better to compact directly borders than setting them null.
|
//better to compact directly borders than setting them null.
|
||||||
|
|
||||||
//finally: there may be duplicated borders
|
//finally: there may be duplicated borders
|
||||||
for(unsigned int p = 0; p < nexus.size(); p++) {
|
for(unsigned int p = 0; p < nexus.size(); p++) {
|
||||||
Border &border = nexus.GetBorder(p);
|
Border &border = nexus.GetBorder(p);
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.7 2005/02/20 18:07:01 ponchio
|
||||||
|
cleaning.
|
||||||
|
|
||||||
Revision 1.6 2005/02/19 10:45:04 ponchio
|
Revision 1.6 2005/02/19 10:45:04 ponchio
|
||||||
Patch generalized and small fixes.
|
Patch generalized and small fixes.
|
||||||
|
|
||||||
|
@ -62,7 +65,7 @@ namespace nxs {
|
||||||
void Unify(Nexus &nexus, float threshold);
|
void Unify(Nexus &nexus, float threshold);
|
||||||
void ZSort(Nexus &nexus, std::vector<unsigned int> &forward,
|
void ZSort(Nexus &nexus, std::vector<unsigned int> &forward,
|
||||||
std::vector<unsigned int> &backward);
|
std::vector<unsigned int> &backward);
|
||||||
void TightSphere(vcg::Sphere3f &sphere, std::vector<vcg::Point3f> &points);
|
// void TightSphere(vcg::Sphere3f &sphere, std::vector<vcg::Point3f> &points);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.19 2005/02/20 18:07:01 ponchio
|
||||||
|
cleaning.
|
||||||
|
|
||||||
Revision 1.18 2005/02/20 00:43:24 ponchio
|
Revision 1.18 2005/02/20 00:43:24 ponchio
|
||||||
Less memory x extraction. (removed frags)
|
Less memory x extraction. (removed frags)
|
||||||
|
|
||||||
|
@ -359,11 +362,7 @@ void ThirdStep(const string &crudefile, const string &output,
|
||||||
memcpy(patch.Vert3fBegin(), &*vertices.begin(), vcount * sizeof(Point3f));
|
memcpy(patch.Vert3fBegin(), &*vertices.begin(), vcount * sizeof(Point3f));
|
||||||
|
|
||||||
Sphere3f &sphere = nexus[patch_idx].sphere;
|
Sphere3f &sphere = nexus[patch_idx].sphere;
|
||||||
for(int i = 0; i < vertices.size(); i++)
|
sphere.CreateTight(vertices.size(), &*vertices.begin());
|
||||||
sphere.Add(vertices[i]);
|
|
||||||
sphere.Radius() *= 1.01;
|
|
||||||
|
|
||||||
TightSphere(sphere, vertices);
|
|
||||||
|
|
||||||
vector<Point3f> normals;
|
vector<Point3f> normals;
|
||||||
for(unsigned int i = 0; i < patch.nf; i++) {
|
for(unsigned int i = 0; i < patch.nf; i++) {
|
||||||
|
@ -379,7 +378,6 @@ void ThirdStep(const string &crudefile, const string &output,
|
||||||
cone.AddNormals(normals, 0.99f);
|
cone.AddNormals(normals, 0.99f);
|
||||||
nexus[patch_idx].cone.Import(cone);
|
nexus[patch_idx].cone.Import(cone);
|
||||||
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
for(int i = 0; i < vertices.size(); i++) {
|
for(int i = 0; i < vertices.size(); i++) {
|
||||||
assert(sphere.IsIn(vertices[i]));
|
assert(sphere.IsIn(vertices[i]));
|
||||||
|
@ -825,6 +823,8 @@ void SaveFragment(Nexus &nexus, VChain &chain,
|
||||||
patch_levels.push_back(current_level);
|
patch_levels.push_back(current_level);
|
||||||
Entry &entry = nexus[patch_idx];
|
Entry &entry = nexus[patch_idx];
|
||||||
entry.error = fragout.error;
|
entry.error = fragout.error;
|
||||||
|
entry.sphere = patch.sphere;
|
||||||
|
entry.cone.Import(patch.cone);
|
||||||
|
|
||||||
patch_remap[i] = patch_idx;
|
patch_remap[i] = patch_idx;
|
||||||
chain.newfragments[patch.patch].insert(patch_idx);
|
chain.newfragments[patch.patch].insert(patch_idx);
|
||||||
|
@ -852,12 +852,6 @@ void SaveFragment(Nexus &nexus, VChain &chain,
|
||||||
outpatch.vert.size() * sizeof(Point3f));
|
outpatch.vert.size() * sizeof(Point3f));
|
||||||
|
|
||||||
Entry &entry = nexus[patch_idx];
|
Entry &entry = nexus[patch_idx];
|
||||||
for(unsigned int v = 0; v < outpatch.vert.size(); v++) {
|
|
||||||
entry.sphere.Add(outpatch.vert[v]);
|
|
||||||
nexus.sphere.Add(outpatch.vert[v]);
|
|
||||||
}
|
|
||||||
entry.sphere.Radius() *= 1.01;
|
|
||||||
TightSphere(entry.sphere, outpatch.vert);
|
|
||||||
|
|
||||||
//remap internal borders
|
//remap internal borders
|
||||||
for(unsigned int k = 0; k < outpatch.bord.size(); k++) {
|
for(unsigned int k = 0; k < outpatch.bord.size(); k++) {
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.24 2005/02/20 19:49:44 ponchio
|
||||||
|
cleaning (a bit more).
|
||||||
|
|
||||||
Revision 1.23 2005/02/20 18:07:01 ponchio
|
Revision 1.23 2005/02/20 18:07:01 ponchio
|
||||||
cleaning.
|
cleaning.
|
||||||
|
|
||||||
|
@ -648,6 +651,11 @@ void printInfo(Nexus &nexus, bool verbose, bool dump_history) {
|
||||||
<< " error: " << entry.error
|
<< " error: " << entry.error
|
||||||
<< " disk_size: " << entry.disk_size
|
<< " disk_size: " << entry.disk_size
|
||||||
<< " start: " << entry.patch_start << endl;
|
<< " start: " << entry.patch_start << endl;
|
||||||
|
cout << " Cone: " << entry.cone.n[0] << " "
|
||||||
|
<< entry.cone.n[1] << " "
|
||||||
|
<< entry.cone.n[2] << " "
|
||||||
|
<< entry.cone.n[3] << "\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.3 2005/01/21 17:09:13 ponchio
|
||||||
|
Porting and debug.
|
||||||
|
|
||||||
Revision 1.2 2004/12/04 13:24:27 ponchio
|
Revision 1.2 2004/12/04 13:24:27 ponchio
|
||||||
Fixed a couple of memory leak...
|
Fixed a couple of memory leak...
|
||||||
|
|
||||||
|
@ -85,13 +88,23 @@ void VPartition::Closest(const vcg::Point3f &p,
|
||||||
point[1] = p[1];
|
point[1] = p[1];
|
||||||
point[2] = p[2];
|
point[2] = p[2];
|
||||||
double dists;
|
double dists;
|
||||||
bd->annkSearch(&point[0], 1, &target, &dists, 1);
|
bd->annkSearch(&point[0], 1, &target, &dists);
|
||||||
assert(target >= 0);
|
assert(target >= 0);
|
||||||
assert(target < size());
|
assert(target < size());
|
||||||
|
|
||||||
dist = (float)dists;
|
dist = (float)dists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VPartition::Closest(const vcg::Point3f &p, unsigned int nsize,
|
||||||
|
int *targets,
|
||||||
|
double *dists) {
|
||||||
|
double point[3];
|
||||||
|
point[0] = p[0];
|
||||||
|
point[1] = p[1];
|
||||||
|
point[2] = p[2];
|
||||||
|
bd->annkSearch(&point[0], nsize, targets, dists);
|
||||||
|
}
|
||||||
|
|
||||||
int VPartition::Locate(const vcg::Point3f &p) {
|
int VPartition::Locate(const vcg::Point3f &p) {
|
||||||
|
|
||||||
double point[3];
|
double point[3];
|
||||||
|
@ -101,7 +114,7 @@ int VPartition::Locate(const vcg::Point3f &p) {
|
||||||
|
|
||||||
int target = -1;
|
int target = -1;
|
||||||
double dists;
|
double dists;
|
||||||
bd->annkSearch(&point[0], 1, &target, &dists, 1);
|
bd->annkSearch(&point[0], 1, &target, &dists);
|
||||||
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.3 2005/01/18 22:46:58 ponchio
|
||||||
|
Small changes.
|
||||||
|
|
||||||
Revision 1.2 2004/12/04 13:24:28 ponchio
|
Revision 1.2 2004/12/04 13:24:28 ponchio
|
||||||
Fixed a couple of memory leak...
|
Fixed a couple of memory leak...
|
||||||
|
|
||||||
|
@ -72,7 +75,10 @@ class VPartition: public std::vector<vcg::Point3f> {
|
||||||
std::vector<float> &dist);
|
std::vector<float> &dist);
|
||||||
void Closest(const vcg::Point3f &p,
|
void Closest(const vcg::Point3f &p,
|
||||||
int &target, float &dist);
|
int &target, float &dist);
|
||||||
|
//most efficient!
|
||||||
|
void Closest(const vcg::Point3f &p, unsigned int nsize,
|
||||||
|
int *targets,
|
||||||
|
double *dists);
|
||||||
|
|
||||||
|
|
||||||
ANNkd_tree *bd;
|
ANNkd_tree *bd;
|
||||||
|
|
Loading…
Reference in New Issue