small GCC compiling issues
This commit is contained in:
parent
4ae1cb2a64
commit
c5f4a75533
|
@ -8,7 +8,7 @@
|
||||||
* \ *
|
* \ *
|
||||||
* All rights reserved. *
|
* All rights reserved. *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
* the Free Software Foundation; either version 2 of the License, or *
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
* (at your option) any later version. *
|
* (at your option) any later version. *
|
||||||
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.19 2006/03/27 04:17:07 cignoni
|
||||||
|
moved to generic export.h
|
||||||
|
|
||||||
Revision 1.18 2006/01/10 13:20:40 cignoni
|
Revision 1.18 2006/01/10 13:20:40 cignoni
|
||||||
Changed ply::PlyMask to io::Mask
|
Changed ply::PlyMask to io::Mask
|
||||||
|
|
||||||
|
@ -83,7 +86,7 @@ GPL added
|
||||||
|
|
||||||
// standard libraries
|
// standard libraries
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
using namespace std;
|
||||||
// project definitions.
|
// project definitions.
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "sampling.h"
|
#include "sampling.h"
|
||||||
|
@ -97,11 +100,11 @@ GPL added
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------
|
||||||
using namespace std;
|
|
||||||
using namespace vcg;
|
using namespace vcg;
|
||||||
|
|
||||||
|
|
||||||
////////////////// Command line Flags and parameters
|
////////////////// Command line Flags and parameters
|
||||||
bool NumberOfSamples = false;
|
bool NumberOfSamples = false;
|
||||||
bool SamplesPerAreaUnit = false;
|
bool SamplesPerAreaUnit = false;
|
||||||
bool CleaningFlag=false;
|
bool CleaningFlag=false;
|
||||||
|
@ -155,7 +158,7 @@ void OpenMesh(const char *filename, CMesh &m)
|
||||||
printf("Error in reading %s: '%s'\n",filename,tri::io::Importer<CMesh>::ErrorMsg(err));
|
printf("Error in reading %s: '%s'\n",filename,tri::io::Importer<CMesh>::ErrorMsg(err));
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
printf("read mesh `%s'\n", filename);
|
printf("read mesh `%s'\n", filename);
|
||||||
if(CleaningFlag){
|
if(CleaningFlag){
|
||||||
int dup = tri::Clean<CMesh>::RemoveDuplicateVertex(m);
|
int dup = tri::Clean<CMesh>::RemoveDuplicateVertex(m);
|
||||||
int unref = tri::Clean<CMesh>::RemoveUnreferencedVertex(m);
|
int unref = tri::Clean<CMesh>::RemoveUnreferencedVertex(m);
|
||||||
|
@ -172,7 +175,7 @@ int main(int argc, char**argv)
|
||||||
unsigned long n_samples_target, elapsed_time;
|
unsigned long n_samples_target, elapsed_time;
|
||||||
double n_samples_per_area_unit;
|
double n_samples_per_area_unit;
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
// print program info
|
// print program info
|
||||||
printf("-------------------------------\n"
|
printf("-------------------------------\n"
|
||||||
" Metro V.4.06 \n"
|
" Metro V.4.06 \n"
|
||||||
|
@ -192,7 +195,7 @@ int main(int argc, char**argv)
|
||||||
{
|
{
|
||||||
if(argv[i][0]=='-')
|
if(argv[i][0]=='-')
|
||||||
switch(argv[i][1])
|
switch(argv[i][1])
|
||||||
{
|
{
|
||||||
case 'h' : flags |= SamplingFlags::HIST; break;
|
case 'h' : flags |= SamplingFlags::HIST; break;
|
||||||
case 'v' : flags &= ~SamplingFlags::VERTEX_SAMPLING; break;
|
case 'v' : flags &= ~SamplingFlags::VERTEX_SAMPLING; break;
|
||||||
case 'e' : flags &= ~SamplingFlags::EDGE_SAMPLING; break;
|
case 'e' : flags &= ~SamplingFlags::EDGE_SAMPLING; break;
|
||||||
|
@ -221,17 +224,17 @@ int main(int argc, char**argv)
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(flags & SamplingFlags::USE_HASH_GRID) && !(flags & SamplingFlags::USE_AABB_TREE) )
|
if(!(flags & SamplingFlags::USE_HASH_GRID) && !(flags & SamplingFlags::USE_AABB_TREE) )
|
||||||
flags |= SamplingFlags::USE_STATIC_GRID;
|
flags |= SamplingFlags::USE_STATIC_GRID;
|
||||||
|
|
||||||
// load input meshes.
|
// load input meshes.
|
||||||
OpenMesh(argv[1],S1);
|
OpenMesh(argv[1],S1);
|
||||||
OpenMesh(argv[2],S2);
|
OpenMesh(argv[2],S2);
|
||||||
|
|
||||||
string S1NewName=SaveFileName(argv[1]);
|
string S1NewName=SaveFileName(argv[1]);
|
||||||
string S2NewName=SaveFileName(argv[2]);
|
string S2NewName=SaveFileName(argv[2]);
|
||||||
|
|
||||||
if(!NumberOfSamples && !SamplesPerAreaUnit)
|
if(!NumberOfSamples && !SamplesPerAreaUnit)
|
||||||
{
|
{
|
||||||
NumberOfSamples = true;
|
NumberOfSamples = true;
|
||||||
|
@ -253,7 +256,7 @@ int main(int argc, char**argv)
|
||||||
bbox.Offset(bbox.Diag()*0.02);
|
bbox.Offset(bbox.Diag()*0.02);
|
||||||
S1.bbox = bbox;
|
S1.bbox = bbox;
|
||||||
S2.bbox = bbox;
|
S2.bbox = bbox;
|
||||||
|
|
||||||
// initialize time info.
|
// initialize time info.
|
||||||
int t0=clock();
|
int t0=clock();
|
||||||
|
|
||||||
|
@ -323,7 +326,7 @@ int main(int argc, char**argv)
|
||||||
elapsed_time = clock() - t0;
|
elapsed_time = clock() - t0;
|
||||||
int n_total_sample=ForwardSampling.GetNSamples()+BackwardSampling.GetNSamples();
|
int n_total_sample=ForwardSampling.GetNSamples()+BackwardSampling.GetNSamples();
|
||||||
double mesh_dist_max = max(dist1_max , dist2_max);
|
double mesh_dist_max = max(dist1_max , dist2_max);
|
||||||
|
|
||||||
printf("\nHausdorff distance: %f (%f wrt bounding box diagonal)\n",(float)mesh_dist_max,(float)mesh_dist_max/bbox.Diag());
|
printf("\nHausdorff distance: %f (%f wrt bounding box diagonal)\n",(float)mesh_dist_max,(float)mesh_dist_max/bbox.Diag());
|
||||||
printf(" Computation time : %d ms\n",(int)(1000.0*elapsed_time/CLOCKS_PER_SEC));
|
printf(" Computation time : %d ms\n",(int)(1000.0*elapsed_time/CLOCKS_PER_SEC));
|
||||||
printf(" # samples/second : %f\n\n", (float)n_total_sample/((float)elapsed_time/CLOCKS_PER_SEC));
|
printf(" # samples/second : %f\n\n", (float)n_total_sample/((float)elapsed_time/CLOCKS_PER_SEC));
|
||||||
|
@ -331,7 +334,7 @@ int main(int argc, char**argv)
|
||||||
// save error files.
|
// save error files.
|
||||||
if(flags & SamplingFlags::SAVE_ERROR)
|
if(flags & SamplingFlags::SAVE_ERROR)
|
||||||
{
|
{
|
||||||
vcg::tri::io::PlyInfo p;
|
vcg::tri::io::PlyInfo p;
|
||||||
p.mask|=vcg::tri::io::Mask::IOM_VERTCOLOR | vcg::tri::io::Mask::IOM_VERTQUALITY /* | vcg::ply::PLYMask::PM_VERTQUALITY*/ ;
|
p.mask|=vcg::tri::io::Mask::IOM_VERTCOLOR | vcg::tri::io::Mask::IOM_VERTQUALITY /* | vcg::ply::PLYMask::PM_VERTQUALITY*/ ;
|
||||||
//p.mask|=vcg::ply::PLYMask::PM_VERTCOLOR|vcg::ply::PLYMask::PM_VERTQUALITY;
|
//p.mask|=vcg::ply::PLYMask::PM_VERTCOLOR|vcg::ply::PLYMask::PM_VERTQUALITY;
|
||||||
if(ColorMax!=0 || ColorMin != 0){
|
if(ColorMax!=0 || ColorMin != 0){
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* \ *
|
* \ *
|
||||||
* All rights reserved. *
|
* All rights reserved. *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
* the Free Software Foundation; either version 2 of the License, or *
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
* (at your option) any later version. *
|
* (at your option) any later version. *
|
||||||
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.21 2006/01/22 10:05:43 cignoni
|
||||||
|
Corrected use of Area with the unambiguous DoubleArea
|
||||||
|
|
||||||
Revision 1.20 2005/11/12 06:44:29 cignoni
|
Revision 1.20 2005/11/12 06:44:29 cignoni
|
||||||
Changed GetClosest -> GetClosestFace
|
Changed GetClosest -> GetClosestFace
|
||||||
|
|
||||||
|
@ -101,7 +104,7 @@ instantiate GridStaticPtr on the simplexClass template.
|
||||||
namespace vcg
|
namespace vcg
|
||||||
{
|
{
|
||||||
|
|
||||||
struct SamplingFlags{
|
struct SamplingFlags{
|
||||||
enum{
|
enum{
|
||||||
HIST = 0x0001,
|
HIST = 0x0001,
|
||||||
VERTEX_SAMPLING = 0x0002,
|
VERTEX_SAMPLING = 0x0002,
|
||||||
|
@ -120,7 +123,7 @@ struct SamplingFlags{
|
||||||
};
|
};
|
||||||
// -----------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------
|
||||||
template <class MetroMesh>
|
template <class MetroMesh>
|
||||||
class Sampling
|
class Sampling
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -141,11 +144,11 @@ private:
|
||||||
|
|
||||||
typedef Point3<typename MetroMesh::ScalarType> Point3x;
|
typedef Point3<typename MetroMesh::ScalarType> Point3x;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// data structures
|
// data structures
|
||||||
MetroMesh &S1;
|
MetroMesh &S1;
|
||||||
MetroMesh &S2;
|
MetroMesh &S2;
|
||||||
MetroMeshGrid gS2;
|
MetroMeshGrid gS2;
|
||||||
MetroMeshHash hS2;
|
MetroMeshHash hS2;
|
||||||
|
@ -161,11 +164,11 @@ private:
|
||||||
int print_every_n_elements ;
|
int print_every_n_elements ;
|
||||||
int referredBit;
|
int referredBit;
|
||||||
// parameters
|
// parameters
|
||||||
double dist_upper_bound;
|
double dist_upper_bound;
|
||||||
double n_samples_per_area_unit;
|
double n_samples_per_area_unit;
|
||||||
unsigned long n_samples_target;
|
unsigned long n_samples_target;
|
||||||
int Flags;
|
int Flags;
|
||||||
|
|
||||||
// results
|
// results
|
||||||
Histogram<double> hist;
|
Histogram<double> hist;
|
||||||
unsigned long n_total_samples;
|
unsigned long n_total_samples;
|
||||||
|
@ -173,7 +176,7 @@ private:
|
||||||
unsigned long n_total_edge_samples;
|
unsigned long n_total_edge_samples;
|
||||||
unsigned long n_total_vertex_samples;
|
unsigned long n_total_vertex_samples;
|
||||||
double max_dist;
|
double max_dist;
|
||||||
double mean_dist;
|
double mean_dist;
|
||||||
double RMS_dist;
|
double RMS_dist;
|
||||||
double volume;
|
double volume;
|
||||||
double area_S1;
|
double area_S1;
|
||||||
|
@ -242,7 +245,7 @@ Sampling<MetroMesh>::Sampling(MetroMesh &_s1, MetroMesh &_s2):S1(_s1),S2(_s2)
|
||||||
// store the unreferred vertices
|
// store the unreferred vertices
|
||||||
FaceIterator fi; VertexIterator vi; int i;
|
FaceIterator fi; VertexIterator vi; int i;
|
||||||
for(fi = _s1.face.begin(); fi!= _s1.face.end(); ++fi)
|
for(fi = _s1.face.begin(); fi!= _s1.face.end(); ++fi)
|
||||||
for(i=0;i<3;++i) (*fi).V(i)->SetUserBit(referredBit);
|
for(i=0;i<3;++i) (*fi).V(i)->SetUserBit(referredBit);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class MetroMesh>
|
template <class MetroMesh>
|
||||||
|
@ -298,11 +301,11 @@ float Sampling<MetroMesh>::AddSample(const Point3x &p )
|
||||||
f=trimesh::GetClosestFace<MetroMesh,MetroMeshHash>(S2, hS2, p, dist_upper_bound, dist, normf, bestq, ip);
|
f=trimesh::GetClosestFace<MetroMesh,MetroMeshHash>(S2, hS2, p, dist_upper_bound, dist, normf, bestq, ip);
|
||||||
if(Flags & SamplingFlags::USE_STATIC_GRID)
|
if(Flags & SamplingFlags::USE_STATIC_GRID)
|
||||||
f=trimesh::GetClosestFace<MetroMesh,MetroMeshGrid>(S2, gS2, p, dist_upper_bound, dist, normf, bestq, ip);
|
f=trimesh::GetClosestFace<MetroMesh,MetroMeshGrid>(S2, gS2, p, dist_upper_bound, dist, normf, bestq, ip);
|
||||||
|
|
||||||
// update distance measures
|
// update distance measures
|
||||||
if(dist == dist_upper_bound)
|
if(dist == dist_upper_bound)
|
||||||
return -1.0;
|
return -1.0;
|
||||||
|
|
||||||
if(dist > max_dist)
|
if(dist > max_dist)
|
||||||
max_dist = dist; // L_inf
|
max_dist = dist; // L_inf
|
||||||
mean_dist += dist; // L_1
|
mean_dist += dist; // L_1
|
||||||
|
@ -312,7 +315,7 @@ float Sampling<MetroMesh>::AddSample(const Point3x &p )
|
||||||
if(Flags & SamplingFlags::HIST)
|
if(Flags & SamplingFlags::HIST)
|
||||||
hist.Add((float)fabs(dist));
|
hist.Add((float)fabs(dist));
|
||||||
|
|
||||||
return (float)dist;
|
return (float)dist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -325,7 +328,7 @@ void Sampling<MetroMesh>::VertexSampling()
|
||||||
// Vertex sampling.
|
// Vertex sampling.
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
float error;
|
float error;
|
||||||
|
|
||||||
printf("Vertex sampling\n");
|
printf("Vertex sampling\n");
|
||||||
VertexIterator vi;
|
VertexIterator vi;
|
||||||
typename std::vector<VertexPointer>::iterator vif;
|
typename std::vector<VertexPointer>::iterator vif;
|
||||||
|
@ -339,7 +342,7 @@ void Sampling<MetroMesh>::VertexSampling()
|
||||||
|
|
||||||
// save vertex quality
|
// save vertex quality
|
||||||
if(Flags & SamplingFlags::SAVE_ERROR) (*vi).Q() = error;
|
if(Flags & SamplingFlags::SAVE_ERROR) (*vi).Q() = error;
|
||||||
|
|
||||||
// print progress information
|
// print progress information
|
||||||
if(!(++cnt % print_every_n_elements))
|
if(!(++cnt % print_every_n_elements))
|
||||||
printf("Sampling vertices %d%%\r", (100 * cnt/S1.vn));
|
printf("Sampling vertices %d%%\r", (100 * cnt/S1.vn));
|
||||||
|
@ -357,7 +360,7 @@ inline void Sampling<MetroMesh>::SampleEdge(const Point3x & v0, const Point3x &
|
||||||
// uniform sampling of the segment v0v1.
|
// uniform sampling of the segment v0v1.
|
||||||
Point3x e((v1-v0)/(double)(n_samples_per_edge+1));
|
Point3x e((v1-v0)/(double)(n_samples_per_edge+1));
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i=1; i <= n_samples_per_edge; i++)
|
for(i=1; i <= n_samples_per_edge; i++)
|
||||||
{
|
{
|
||||||
AddSample(v0 + e*i);
|
AddSample(v0 + e*i);
|
||||||
|
@ -381,7 +384,7 @@ void Sampling<MetroMesh>::EdgeSampling()
|
||||||
for(int i=0; i<3; ++i)
|
for(int i=0; i<3; ++i)
|
||||||
{
|
{
|
||||||
Edges.push_back(make_pair((*fi).V0(i),(*fi).V1(i)));
|
Edges.push_back(make_pair((*fi).V0(i),(*fi).V1(i)));
|
||||||
if(Edges.back().first > Edges.back().second)
|
if(Edges.back().first > Edges.back().second)
|
||||||
swap(Edges.back().first, Edges.back().second);
|
swap(Edges.back().first, Edges.back().second);
|
||||||
}
|
}
|
||||||
sort(Edges.begin(), Edges.end());
|
sort(Edges.begin(), Edges.end());
|
||||||
|
@ -480,7 +483,7 @@ template <class MetroMesh>
|
||||||
void Sampling<MetroMesh>::FaceSubdiv(const Point3x & v0, const Point3x & v1, const Point3x & v2, int maxdepth)
|
void Sampling<MetroMesh>::FaceSubdiv(const Point3x & v0, const Point3x & v1, const Point3x & v2, int maxdepth)
|
||||||
{
|
{
|
||||||
// recursive face subdivision.
|
// recursive face subdivision.
|
||||||
if(maxdepth == 0)
|
if(maxdepth == 0)
|
||||||
{
|
{
|
||||||
// ground case.
|
// ground case.
|
||||||
AddSample((v0+v1+v2)/3.0f);
|
AddSample((v0+v1+v2)/3.0f);
|
||||||
|
@ -494,7 +497,7 @@ void Sampling<MetroMesh>::FaceSubdiv(const Point3x & v0, const Point3x & v1, con
|
||||||
double maxd12 = SquaredDistance(v1,v2);
|
double maxd12 = SquaredDistance(v1,v2);
|
||||||
double maxd20 = SquaredDistance(v2,v0);
|
double maxd20 = SquaredDistance(v2,v0);
|
||||||
int res;
|
int res;
|
||||||
if(maxd01 > maxd12)
|
if(maxd01 > maxd12)
|
||||||
if(maxd01 > maxd20) res = 0;
|
if(maxd01 > maxd20) res = 0;
|
||||||
else res = 2;
|
else res = 2;
|
||||||
else
|
else
|
||||||
|
@ -503,17 +506,17 @@ void Sampling<MetroMesh>::FaceSubdiv(const Point3x & v0, const Point3x & v1, con
|
||||||
|
|
||||||
// break the input triangle along the median to the the longest edge.
|
// break the input triangle along the median to the the longest edge.
|
||||||
Point3x pp;
|
Point3x pp;
|
||||||
switch(res)
|
switch(res)
|
||||||
{
|
{
|
||||||
case 0 : pp = (v0+v1)/2;
|
case 0 : pp = (v0+v1)/2;
|
||||||
FaceSubdiv(v0,pp,v2,maxdepth-1);
|
FaceSubdiv(v0,pp,v2,maxdepth-1);
|
||||||
FaceSubdiv(pp,v1,v2,maxdepth-1);
|
FaceSubdiv(pp,v1,v2,maxdepth-1);
|
||||||
break;
|
break;
|
||||||
case 1 : pp = (v1+v2)/2;
|
case 1 : pp = (v1+v2)/2;
|
||||||
FaceSubdiv(v0,v1,pp,maxdepth-1);
|
FaceSubdiv(v0,v1,pp,maxdepth-1);
|
||||||
FaceSubdiv(v0,pp,v2,maxdepth-1);
|
FaceSubdiv(v0,pp,v2,maxdepth-1);
|
||||||
break;
|
break;
|
||||||
case 2 : pp = (v2+v0)/2;
|
case 2 : pp = (v2+v0)/2;
|
||||||
FaceSubdiv(v0,v1,pp,maxdepth-1);
|
FaceSubdiv(v0,v1,pp,maxdepth-1);
|
||||||
FaceSubdiv(pp,v1,v2,maxdepth-1);
|
FaceSubdiv(pp,v1,v2,maxdepth-1);
|
||||||
break;
|
break;
|
||||||
|
@ -608,15 +611,15 @@ void Sampling<MetroMesh>::Hausdorff()
|
||||||
{
|
{
|
||||||
Box3< ScalarType> bbox;
|
Box3< ScalarType> bbox;
|
||||||
|
|
||||||
|
typedef typename std::vector<FaceType>::iterator FaceVecIterator;
|
||||||
// set grid meshes.
|
// set grid meshes.
|
||||||
if(Flags & SamplingFlags::USE_HASH_GRID)
|
if(Flags & SamplingFlags::USE_HASH_GRID)
|
||||||
hS2.Set<vector<FaceType>::iterator>(S2.face.begin(),S2.face.end());
|
hS2.Set(S2.face.begin(),S2.face.end());
|
||||||
if(Flags & SamplingFlags::USE_AABB_TREE)
|
if(Flags & SamplingFlags::USE_AABB_TREE)
|
||||||
tS2.Set<vector<FaceType>::iterator>(S2.face.begin(),S2.face.end());
|
tS2.Set(S2.face.begin(),S2.face.end());
|
||||||
if(Flags & SamplingFlags::USE_STATIC_GRID)
|
if(Flags & SamplingFlags::USE_STATIC_GRID)
|
||||||
gS2.Set<vector<FaceType>::iterator>(S2.face.begin(),S2.face.end());
|
gS2.Set(S2.face.begin(),S2.face.end());
|
||||||
|
|
||||||
// set bounding box
|
// set bounding box
|
||||||
bbox = S2.bbox;
|
bbox = S2.bbox;
|
||||||
dist_upper_bound = /*bbox_factor * */bbox.Diag();
|
dist_upper_bound = /*bbox_factor * */bbox.Diag();
|
||||||
|
@ -655,7 +658,7 @@ void Sampling<MetroMesh>::Hausdorff()
|
||||||
// compute vertex colour
|
// compute vertex colour
|
||||||
if(Flags & SamplingFlags::SAVE_ERROR)
|
if(Flags & SamplingFlags::SAVE_ERROR)
|
||||||
vcg::tri::UpdateColor<MetroMesh>::VertexQuality(S1);
|
vcg::tri::UpdateColor<MetroMesh>::VertexQuality(S1);
|
||||||
|
|
||||||
// compute statistics
|
// compute statistics
|
||||||
n_samples_per_area_unit = (double) n_total_samples / area_S1;
|
n_samples_per_area_unit = (double) n_total_samples / area_S1;
|
||||||
volume = mean_dist / n_samples_per_area_unit / 2.0;
|
volume = mean_dist / n_samples_per_area_unit / 2.0;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* \ *
|
* \ *
|
||||||
* All rights reserved. *
|
* All rights reserved. *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
* the Free Software Foundation; either version 2 of the License, or *
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
* (at your option) any later version. *
|
* (at your option) any later version. *
|
||||||
|
@ -24,6 +24,11 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.17 2006/01/23 21:26:57 ponchio
|
||||||
|
gcc compatibility (templates mostly)
|
||||||
|
bbox -> this->bbox
|
||||||
|
More consistent use of Box3x and such.
|
||||||
|
|
||||||
Revision 1.16 2006/01/23 15:26:31 ponchio
|
Revision 1.16 2006/01/23 15:26:31 ponchio
|
||||||
P1 --> HASH_P1
|
P1 --> HASH_P1
|
||||||
Old definition was conflicting with functions in segment.h
|
Old definition was conflicting with functions in segment.h
|
||||||
|
@ -112,7 +117,7 @@ namespace vcg{
|
||||||
|
|
||||||
/** Spatial Hash Table
|
/** Spatial Hash Table
|
||||||
Spatial Hashing as described in
|
Spatial Hashing as described in
|
||||||
"Optimized Spatial Hashing for Coll ision Detection of Deformable Objects",
|
"Optimized Spatial Hashing for Coll ision Detection of Deformable Objects",
|
||||||
Matthias Teschner and Bruno Heidelberger and Matthias Muller and Danat Pomeranets and Markus Gross
|
Matthias Teschner and Bruno Heidelberger and Matthias Muller and Danat Pomeranets and Markus Gross
|
||||||
*/
|
*/
|
||||||
template < typename OBJTYPE,class FLT=double>
|
template < typename OBJTYPE,class FLT=double>
|
||||||
|
@ -121,7 +126,7 @@ namespace vcg{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef OBJTYPE ObjType;
|
typedef OBJTYPE ObjType;
|
||||||
typedef ObjType* ObjPtr;
|
typedef ObjType* ObjPtr;
|
||||||
typedef typename ObjType::ScalarType ScalarType;
|
typedef typename ObjType::ScalarType ScalarType;
|
||||||
typedef Point3<ScalarType> CoordType;
|
typedef Point3<ScalarType> CoordType;
|
||||||
|
@ -158,7 +163,7 @@ namespace vcg{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//elements
|
//elements
|
||||||
CellContainerType _entries;
|
CellContainerType _entries;
|
||||||
|
|
||||||
Cell()
|
Cell()
|
||||||
|
@ -197,10 +202,10 @@ namespace vcg{
|
||||||
Point3i CellN()
|
Point3i CellN()
|
||||||
{return cell_n;}
|
{return cell_n;}
|
||||||
|
|
||||||
bool operator ==(const Cell &h)
|
bool operator ==(const Cell &h)
|
||||||
{return (cell_n==h.CellN());}
|
{return (cell_n==h.CellN());}
|
||||||
|
|
||||||
bool operator !=(const Cell &h)
|
bool operator !=(const Cell &h)
|
||||||
{return ((cell_n!=h.CellN()));}
|
{return ((cell_n!=h.CellN()));}
|
||||||
|
|
||||||
}; // end struct Cell
|
}; // end struct Cell
|
||||||
|
@ -309,16 +314,16 @@ namespace vcg{
|
||||||
_UpdateHMark(s);
|
_UpdateHMark(s);
|
||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Insert a mesh in the grid.
|
/// Insert a mesh in the grid.
|
||||||
template <class OBJITER>
|
template <class OBJITER>
|
||||||
void Set(const OBJITER & _oBegin, const OBJITER & _oEnd,const Box3x &_bbox=Box3x() )
|
void Set(const OBJITER & _oBegin, const OBJITER & _oEnd,const Box3x &_bbox=Box3x() )
|
||||||
{
|
{
|
||||||
|
|
||||||
OBJITER i;
|
OBJITER i;
|
||||||
Box3x b;
|
Box3x b;
|
||||||
Box3x &bbox = this->bbox;
|
Box3x &bbox = this->bbox;
|
||||||
CoordType &dim = this->dim;
|
CoordType &dim = this->dim;
|
||||||
Point3i &siz = this->siz;
|
Point3i &siz = this->siz;
|
||||||
CoordType &voxel = this->voxel;
|
CoordType &voxel = this->voxel;
|
||||||
|
@ -336,8 +341,8 @@ namespace vcg{
|
||||||
ScalarType infl=bbox.Diag()/_size;
|
ScalarType infl=bbox.Diag()/_size;
|
||||||
bbox.min -= CoordType(infl,infl,infl);
|
bbox.min -= CoordType(infl,infl,infl);
|
||||||
bbox.max += CoordType(infl,infl,infl);
|
bbox.max += CoordType(infl,infl,infl);
|
||||||
}
|
}
|
||||||
|
|
||||||
dim = bbox.max - bbox.min;
|
dim = bbox.max - bbox.min;
|
||||||
BestDim( _size, dim, siz );
|
BestDim( _size, dim, siz );
|
||||||
// find voxel size
|
// find voxel size
|
||||||
|
@ -355,17 +360,17 @@ namespace vcg{
|
||||||
{
|
{
|
||||||
IteHtable I;
|
IteHtable I;
|
||||||
vcg::Point3i _c;
|
vcg::Point3i _c;
|
||||||
PToIP(p,_c);
|
this->PToIP(p,_c);
|
||||||
Grid(_c,first,last);
|
Grid(_c,first,last);
|
||||||
}
|
}
|
||||||
|
|
||||||
///return the simplexes on a specified cell
|
///return the simplexes on a specified cell
|
||||||
void Grid( int x,int y,int z, CellIterator & first, CellIterator & last )
|
void Grid( int x,int y,int z, CellIterator & first, CellIterator & last )
|
||||||
{
|
{
|
||||||
Grid(vcg::Point3i(x,y,z),first,last);
|
Grid(vcg::Point3i(x,y,z),first,last);
|
||||||
}
|
}
|
||||||
|
|
||||||
///return the simplexes on a specified cell
|
///return the simplexes on a specified cell
|
||||||
void Grid( const Point3i & _c, CellIterator & first, CellIterator & last )
|
void Grid( const Point3i & _c, CellIterator & first, CellIterator & last )
|
||||||
{
|
{
|
||||||
IteHtable I;
|
IteHtable I;
|
||||||
|
@ -374,7 +379,7 @@ namespace vcg{
|
||||||
first= &*(*I).second._entries.begin();
|
first= &*(*I).second._entries.begin();
|
||||||
last= &*(*I).second._entries.end();
|
last= &*(*I).second._entries.end();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ ///return 2 equals pointers
|
{ ///return 2 equals pointers
|
||||||
first=&*(*hash_table.begin()).second._entries.begin();
|
first=&*(*hash_table.begin()).second._entries.begin();
|
||||||
last= &*(*hash_table.begin()).second._entries.begin();
|
last= &*(*hash_table.begin()).second._entries.begin();
|
||||||
|
@ -409,7 +414,7 @@ namespace vcg{
|
||||||
|
|
||||||
|
|
||||||
template <class OBJPOINTDISTFUNCTOR, class OBJMARKER>
|
template <class OBJPOINTDISTFUNCTOR, class OBJMARKER>
|
||||||
ObjPtr GetClosest(OBJPOINTDISTFUNCTOR & _getPointDistance, OBJMARKER & _marker,
|
ObjPtr GetClosest(OBJPOINTDISTFUNCTOR & _getPointDistance, OBJMARKER & _marker,
|
||||||
const CoordType & _p, const ScalarType & _maxDist,ScalarType & _minDist, CoordType & _closestPt)
|
const CoordType & _p, const ScalarType & _maxDist,ScalarType & _minDist, CoordType & _closestPt)
|
||||||
{
|
{
|
||||||
return (vcg::GridClosest<SpatialHashType,OBJPOINTDISTFUNCTOR,OBJMARKER>(*this,_getPointDistance,_marker, _p,_maxDist,_minDist,_closestPt));
|
return (vcg::GridClosest<SpatialHashType,OBJPOINTDISTFUNCTOR,OBJMARKER>(*this,_getPointDistance,_marker, _p,_maxDist,_minDist,_closestPt));
|
||||||
|
@ -417,7 +422,7 @@ namespace vcg{
|
||||||
|
|
||||||
|
|
||||||
template <class OBJPOINTDISTFUNCTOR, class OBJMARKER, class OBJPTRCONTAINER,class DISTCONTAINER, class POINTCONTAINER>
|
template <class OBJPOINTDISTFUNCTOR, class OBJMARKER, class OBJPTRCONTAINER,class DISTCONTAINER, class POINTCONTAINER>
|
||||||
unsigned int GetKClosest(OBJPOINTDISTFUNCTOR & _getPointDistance,OBJMARKER & _marker,
|
unsigned int GetKClosest(OBJPOINTDISTFUNCTOR & _getPointDistance,OBJMARKER & _marker,
|
||||||
const unsigned int _k, const CoordType & _p, const ScalarType & _maxDist,OBJPTRCONTAINER & _objectPtrs,
|
const unsigned int _k, const CoordType & _p, const ScalarType & _maxDist,OBJPTRCONTAINER & _objectPtrs,
|
||||||
DISTCONTAINER & _distances, POINTCONTAINER & _points)
|
DISTCONTAINER & _distances, POINTCONTAINER & _points)
|
||||||
{
|
{
|
||||||
|
@ -425,14 +430,14 @@ namespace vcg{
|
||||||
OBJPOINTDISTFUNCTOR,OBJMARKER,OBJPTRCONTAINER,DISTCONTAINER,POINTCONTAINER>
|
OBJPOINTDISTFUNCTOR,OBJMARKER,OBJPTRCONTAINER,DISTCONTAINER,POINTCONTAINER>
|
||||||
(*this,_getPointDistance,_marker,_k,_p,_maxDist,_objectPtrs,_distances,_points));
|
(*this,_getPointDistance,_marker,_k,_p,_maxDist,_objectPtrs,_distances,_points));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class OBJPOINTDISTFUNCTOR, class OBJMARKER, class OBJPTRCONTAINER, class DISTCONTAINER, class POINTCONTAINER>
|
template <class OBJPOINTDISTFUNCTOR, class OBJMARKER, class OBJPTRCONTAINER, class DISTCONTAINER, class POINTCONTAINER>
|
||||||
unsigned int GetInSphere(OBJPOINTDISTFUNCTOR & _getPointDistance,
|
unsigned int GetInSphere(OBJPOINTDISTFUNCTOR & _getPointDistance,
|
||||||
OBJMARKER & _marker,
|
OBJMARKER & _marker,
|
||||||
const CoordType & _p,
|
const CoordType & _p,
|
||||||
const ScalarType & _r,
|
const ScalarType & _r,
|
||||||
OBJPTRCONTAINER & _objectPtrs,
|
OBJPTRCONTAINER & _objectPtrs,
|
||||||
DISTCONTAINER & _distances,
|
DISTCONTAINER & _distances,
|
||||||
POINTCONTAINER & _points)
|
POINTCONTAINER & _points)
|
||||||
{
|
{
|
||||||
return(vcg::GridGetInSphere<SpatialHashType,
|
return(vcg::GridGetInSphere<SpatialHashType,
|
||||||
|
@ -441,16 +446,16 @@ namespace vcg{
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class OBJMARKER, class OBJPTRCONTAINER>
|
template <class OBJMARKER, class OBJPTRCONTAINER>
|
||||||
unsigned int GetInBox(OBJMARKER & _marker,
|
unsigned int GetInBox(OBJMARKER & _marker,
|
||||||
const Box3x _bbox,
|
const Box3x _bbox,
|
||||||
OBJPTRCONTAINER & _objectPtrs)
|
OBJPTRCONTAINER & _objectPtrs)
|
||||||
{
|
{
|
||||||
return(vcg::GridGetInBox<SpatialHashType,OBJMARKER,OBJPTRCONTAINER>
|
return(vcg::GridGetInBox<SpatialHashType,OBJMARKER,OBJPTRCONTAINER>
|
||||||
(*this,_marker,_bbox,_objectPtrs));
|
(*this,_marker,_bbox,_objectPtrs));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class OBJRAYISECTFUNCTOR, class OBJMARKER>
|
template <class OBJRAYISECTFUNCTOR, class OBJMARKER>
|
||||||
ObjPtr DoRay(OBJRAYISECTFUNCTOR & _rayIntersector, OBJMARKER & _marker, const Ray3<ScalarType> & _ray, const ScalarType & _maxDist, ScalarType & _t)
|
ObjPtr DoRay(OBJRAYISECTFUNCTOR & _rayIntersector, OBJMARKER & _marker, const Ray3<ScalarType> & _ray, const ScalarType & _maxDist, ScalarType & _t)
|
||||||
{
|
{
|
||||||
return(vcg::GridDoRay<SpatialHashType,OBJRAYISECTFUNCTOR,OBJMARKER>
|
return(vcg::GridDoRay<SpatialHashType,OBJRAYISECTFUNCTOR,OBJMARKER>
|
||||||
(*this,_rayIntersector,_marker,_ray,_maxDist,_t));
|
(*this,_rayIntersector,_marker,_ray,_maxDist,_t));
|
||||||
|
@ -474,12 +479,12 @@ namespace vcg{
|
||||||
typedef typename SpatialHashTable<ContainerType,FLT>::CellIterator CellIterator;
|
typedef typename SpatialHashTable<ContainerType,FLT>::CellIterator CellIterator;
|
||||||
|
|
||||||
void _UpdateHMark(ObjType* s){ s->HMark() = this->tempMark;}
|
void _UpdateHMark(ObjType* s){ s->HMark() = this->tempMark;}
|
||||||
|
|
||||||
/// create an empty spatial hash table
|
/// create an empty spatial hash table
|
||||||
void InitEmpty(const Box3x &_bbox, vcg::Point3i grid_size)
|
void InitEmpty(const Box3x &_bbox, vcg::Point3i grid_size)
|
||||||
{
|
{
|
||||||
Box3x b;
|
Box3x b;
|
||||||
Box3x &bbox = this->bbox;
|
Box3x &bbox = this->bbox;
|
||||||
CoordType &dim = this->dim;
|
CoordType &dim = this->dim;
|
||||||
Point3i &siz = this->size;
|
Point3i &siz = this->size;
|
||||||
CoordType &voxel = this->voxel;
|
CoordType &voxel = this->voxel;
|
||||||
|
@ -507,7 +512,7 @@ namespace vcg{
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}// end namespace
|
}// end namespace
|
||||||
|
|
Loading…
Reference in New Issue