general comment for metro files: modification to comply g++ compiler
This commit is contained in:
parent
cfbe1314df
commit
d6aec85fb0
|
@ -34,7 +34,7 @@
|
|||
//#include <vcg/tools/plylib.h>
|
||||
#include <vcg/simplex/vertex/with/cmnq.h>
|
||||
#include <vcg/simplex/face/with/rtfmfn.h>
|
||||
#include <vcg/space/index/grid_static_obj.h>
|
||||
#include <vcg/space/index/grid_static_ptr.h>
|
||||
#include <vcg/complex/trimesh/base.h>
|
||||
|
||||
|
||||
|
@ -46,9 +46,7 @@ using namespace std;
|
|||
class MyEdge;
|
||||
class CFace;
|
||||
class CVertex : public VertexCMNQ< double,MyEdge,CFace > {};
|
||||
class CFace : public FaceRTFMFN< CVertex > {public:
|
||||
CFace*& F(const int j){ return (CFace*&) FaceRTFMFN<CVertex>::F(j);}
|
||||
};
|
||||
class CFace : public FaceRTFMFN< CVertex,MyEdge,CFace > {};
|
||||
class CMesh : public tri::TriMesh< vector<CVertex>, vector<CFace> > {};
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -36,7 +36,8 @@ bool SaveErrorAsColour = false;
|
|||
|
||||
inline char* GetExtension(char* filename)
|
||||
{
|
||||
for(int i=strlen(filename)-1; i >= 0; i--)
|
||||
size_t i;
|
||||
for( i=strlen(filename)-1; i >= 0; i--)
|
||||
if(filename[i] == '.')
|
||||
break;
|
||||
if(i > 0)
|
||||
|
@ -46,18 +47,18 @@ inline char* GetExtension(char* filename)
|
|||
}
|
||||
|
||||
|
||||
void main(int argc, char**argv)
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
CMesh S1, S2;
|
||||
double dist1_max, dist1_mean, dist1_RMS, volume_1;
|
||||
double dist2_max, dist2_mean, dist2_RMS, volume_2;
|
||||
double mesh_dist_max;
|
||||
unsigned long n_samples_target, n_samples_output, elapsed_time;
|
||||
double n_samples_per_area_unit;
|
||||
double n_samples_per_area_unit;
|
||||
int flags, flags_fwd, flags_back, n_samples_area, n_samples_edge, n_samples_vertex, err;
|
||||
char *fmt, *hist_filename, *new_mesh_filename, *new_mesh_filename_2;
|
||||
char fname_1[] = STR_NEW_MESH_FILENAME_DEFAULT, fname_2[] = STR_NEW_MESH_FILENAME_DEFAULT_2;
|
||||
FILE *fd;
|
||||
//FILE *fd;
|
||||
|
||||
// print program info
|
||||
printf("-------------------------------\n"
|
||||
|
@ -78,13 +79,13 @@ void main(int argc, char**argv)
|
|||
printf(MSG_ERR_UNKNOWN_FORMAT, fmt);
|
||||
exit(-1);
|
||||
}
|
||||
if(!_stricmp(FILE_EXT_PLY, fmt))
|
||||
{
|
||||
if(!strcmp(FILE_EXT_PLY, fmt))
|
||||
{
|
||||
printf("reading the mesh `%s'...", argv[1]);
|
||||
err = tri::io::ImporterPLY<CMesh>::Open(S1,argv[1]);
|
||||
}
|
||||
/* else
|
||||
if(!_stricmp(FILE_EXT_SMF, fmt))
|
||||
if(!strcmp(FILE_EXT_SMF, fmt))
|
||||
{
|
||||
printf("reading the mesh `%s'...", argv[1]);
|
||||
err = tri::io::ImporterSMF::Open(S1,argv[1]);
|
||||
|
@ -109,13 +110,13 @@ void main(int argc, char**argv)
|
|||
printf(MSG_ERR_UNKNOWN_FORMAT, fmt);
|
||||
exit(-1);
|
||||
}
|
||||
if(!_stricmp(FILE_EXT_PLY, fmt))
|
||||
if(!strcmp(FILE_EXT_PLY, fmt))
|
||||
{
|
||||
printf("reading the mesh `%s'...", argv[2]);
|
||||
err = tri::io::ImporterPLY<CMesh>::Open(S2,argv[2]);
|
||||
}
|
||||
/*else
|
||||
if(!_stricmp(FILE_EXT_SMF, fmt))
|
||||
if(!strcmp(FILE_EXT_SMF, fmt))
|
||||
{
|
||||
printf("reading the mesh `%s'...", argv[2]);
|
||||
err = S2.Load_Smf(argv[2]);
|
||||
|
@ -156,8 +157,8 @@ void main(int argc, char**argv)
|
|||
exit(0);
|
||||
}
|
||||
break;
|
||||
case CMD_LINE_ARG_N_SAMPLES : NumberOfSamples = true; n_samples_target = atoi(&(argv[i][2])); break;
|
||||
case CMD_LINE_ARG_SAMPLES_PER_AREA_UNIT : SamplesPerAreaUnit = true; n_samples_per_area_unit = (double) atof(&(argv[i][2])); break;
|
||||
case CMD_LINE_ARG_N_SAMPLES : NumberOfSamples = true; n_samples_target = (unsigned long) atoi(&(argv[i][2])); break;
|
||||
case CMD_LINE_ARG_SAMPLES_PER_AREA_UNIT : SamplesPerAreaUnit = true; n_samples_per_area_unit = (unsigned long) atoi(&(argv[i][2])); break;
|
||||
case CMD_LINE_ARG_SAVE_DISPLACEMENT : SaveErrorDisplacement = true; new_mesh_filename = &(argv[i][2]);
|
||||
if(new_mesh_filename[0] == '\0')
|
||||
new_mesh_filename = fname_1;
|
||||
|
@ -370,6 +371,7 @@ void main(int argc, char**argv)
|
|||
//else
|
||||
// if(flags_back & FLAG_SAVE_ERROR_AS_COLOUR)
|
||||
// S2.SavePly(new_mesh_filename_2, CMesh::SM_ALL & (CMesh::SM_ALL ^ CMesh::SM_VERTQUALITY));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -42,8 +42,12 @@
|
|||
#include <math.h>
|
||||
|
||||
#include <vcg/space/point3.h>
|
||||
#include <vcg/space/box3.h>
|
||||
#include <vcg/space/Point4.h>
|
||||
#include <vcg/math/base.h>
|
||||
#include <vcg/space/index/grid_static_ptr.h>
|
||||
|
||||
|
||||
using namespace vcg;
|
||||
|
||||
|
||||
|
@ -68,7 +72,7 @@ void MinDistPoint( MESH & mesh, const Point3<SCALAR> & p, GRID & gr, SCALAR & md
|
|||
typedef Box3<SCALAR> Box3x;
|
||||
|
||||
if(!gr.bbox.IsIn(p)) return;
|
||||
typedef GridStaticObj<typename MESH::FaceContainer>::Link A2UGridLink;
|
||||
typedef typename GridStaticPtr<typename MESH::FaceContainer>::Link A2UGridLink;
|
||||
scalar ax = p[0] - gr.bbox.min[0]; // Real coodinate of point refer to
|
||||
scalar ay = p[1] - gr.bbox.min[1];
|
||||
scalar az = p[2] - gr.bbox.min[2];
|
||||
|
@ -107,7 +111,7 @@ void MinDistPoint( MESH & mesh, const Point3<SCALAR> & p, GRID & gr, SCALAR & md
|
|||
//scalar error = gr.bbox.Diag();
|
||||
scalar error = mdist;
|
||||
Point3x q;
|
||||
MESH::FaceIterator bestf = 0;
|
||||
typename MESH::FaceIterator bestf = (typename MESH::FaceIterator)0;
|
||||
|
||||
mesh.UnMarkAll();
|
||||
|
||||
|
@ -129,7 +133,7 @@ void MinDistPoint( MESH & mesh, const Point3<SCALAR> & p, GRID & gr, SCALAR & md
|
|||
{
|
||||
bestq = q;
|
||||
bestf = l->Elem();
|
||||
MESH::ScalarType alfa=1, beta=1, gamma=1;
|
||||
typename MESH::ScalarType alfa=1, beta=1, gamma=1;
|
||||
|
||||
//bestf->InterpolationParameters(q, alfa, beta);
|
||||
//calcolo normale con interpolazione trilineare
|
||||
|
@ -171,7 +175,7 @@ void MinDistPoint( MESH & mesh, const Point3<SCALAR> & p, GRID & gr, SCALAR & md
|
|||
{
|
||||
bestq = q;
|
||||
bestf = l->Elem();
|
||||
MESH::ScalarType alfa, beta, gamma;
|
||||
typename MESH::ScalarType alfa, beta, gamma;
|
||||
//bestf->InterpolationParameters(q, alfa, beta);
|
||||
//calcolo normale con interpolazione trilineare
|
||||
bestf->InterpolationParameters(q, alfa, beta, gamma);
|
||||
|
@ -203,4 +207,4 @@ void MinDistPoint( MESH & mesh, const Point3<SCALAR> & p, GRID & gr, SCALAR & md
|
|||
Point3<SCALAR> ip;
|
||||
MinDistPoint(mesh,p,gr,mdist,normf,bestq,f,ip);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
//#include <vcg/tools/Align/Hist.h>
|
||||
#include <vcg/space/box3.h>
|
||||
#include <vcg/space/color4.h>
|
||||
#include <vcg/space/index/grid_static_obj.h>
|
||||
#include <vcg/space/index/grid_static_ptr.h>
|
||||
using namespace vcg;
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -67,7 +67,7 @@ template <class MetroMesh>
|
|||
class Sampling
|
||||
{
|
||||
private:
|
||||
typedef GridStaticObj< typename MetroMesh::FaceContainer > MetroMeshGrid;
|
||||
typedef GridStaticPtr< typename MetroMesh::FaceContainer > MetroMeshGrid;
|
||||
typedef Point3<typename MetroMesh::ScalarType> Point3x;
|
||||
|
||||
// data structures
|
||||
|
@ -78,8 +78,8 @@ private:
|
|||
|
||||
// parameters
|
||||
double dist_upper_bound;
|
||||
double n_samples_per_area_unit;
|
||||
double n_samples_target;
|
||||
double n_samples_per_area_unit;
|
||||
unsigned long n_samples_target;
|
||||
int Flags;
|
||||
|
||||
// results
|
||||
|
@ -119,17 +119,17 @@ public :
|
|||
double GetDistMean() {return mean_dist;}
|
||||
double GetDistRMS() {return RMS_dist;}
|
||||
double GetDistVolume() {return volume;}
|
||||
double GetNSamples() {return n_total_samples;}
|
||||
double GetNAreaSamples() {return n_total_area_samples;}
|
||||
double GetNEdgeSamples() {return n_total_edge_samples;}
|
||||
double GetNVertexSamples() {return n_total_vertex_samples;}
|
||||
double GetNSamplesPerAreaUnit() {return n_samples_per_area_unit;}
|
||||
double GetNSamplesTarget() {return n_samples_target;}
|
||||
unsigned long GetNSamples() {return n_total_samples;}
|
||||
unsigned long GetNAreaSamples() {return n_total_area_samples;}
|
||||
unsigned long GetNEdgeSamples() {return n_total_edge_samples;}
|
||||
unsigned long GetNVertexSamples() {return n_total_vertex_samples;}
|
||||
double GetNSamplesPerAreaUnit() {return n_samples_per_area_unit;}
|
||||
unsigned long GetNSamplesTarget() {return n_samples_target;}
|
||||
// Hist &GetHist() {return hist;}
|
||||
void SetFlags(int flags) {Flags = flags;}
|
||||
void ClearFlag(int flag) {Flags &= (flag ^ -1);}
|
||||
void SetParam(double _n_samp) {n_samples_target = _n_samp;}
|
||||
void SetSamplesTarget(int _n_samp);
|
||||
void SetSamplesTarget(unsigned long _n_samp);
|
||||
void SetSamplesPerAreaUnit(double _n_samp);
|
||||
};
|
||||
|
||||
|
@ -146,17 +146,17 @@ Sampling<MetroMesh>::Sampling(MetroMesh &_s1, MetroMesh &_s2):S1(_s1),S2(_s2)
|
|||
|
||||
// set sampling parameters
|
||||
template <class MetroMesh>
|
||||
void Sampling<MetroMesh>::SetSamplesTarget(int _n_samp)
|
||||
void Sampling<MetroMesh>::SetSamplesTarget(unsigned long _n_samp)
|
||||
{
|
||||
n_samples_target = _n_samp;
|
||||
n_samples_per_area_unit = (double) n_samples_target / area_S1;
|
||||
n_samples_per_area_unit = n_samples_target / (double)area_S1;
|
||||
}
|
||||
|
||||
template <class MetroMesh>
|
||||
void Sampling<MetroMesh>::SetSamplesPerAreaUnit(double _n_samp)
|
||||
{
|
||||
n_samples_per_area_unit = _n_samp;
|
||||
n_samples_target = (int)((double) n_samples_per_area_unit * area_S1);
|
||||
n_samples_target = (unsigned long)((double) n_samples_per_area_unit * area_S1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -164,7 +164,7 @@ void Sampling<MetroMesh>::SetSamplesPerAreaUnit(double _n_samp)
|
|||
template <class MetroMesh>
|
||||
inline double Sampling<MetroMesh>::ComputeMeshArea(MetroMesh & mesh)
|
||||
{
|
||||
MetroMesh::FaceIterator face;
|
||||
typename MetroMesh::FaceIterator face;
|
||||
double area = 0.0;
|
||||
|
||||
for(face=mesh.face.begin(); face != mesh.face.end(); face++)
|
||||
|
@ -177,9 +177,9 @@ inline double Sampling<MetroMesh>::ComputeMeshArea(MetroMesh & mesh)
|
|||
template <class MetroMesh>
|
||||
float Sampling<MetroMesh>::AddSample(const Point3x &p)
|
||||
{
|
||||
MetroMesh::FaceType *f=0;
|
||||
typename MetroMesh::FaceType *f=0;
|
||||
Point3x normf, bestq, ip;
|
||||
MetroMesh::ScalarType dist;
|
||||
typename MetroMesh::ScalarType dist;
|
||||
|
||||
dist = dist_upper_bound;
|
||||
|
||||
|
@ -214,7 +214,7 @@ void Sampling<MetroMesh>::VertexSampling()
|
|||
float error;
|
||||
|
||||
printf("Vertex sampling\n");
|
||||
MetroMesh::VertexIterator vi;
|
||||
typename MetroMesh::VertexIterator vi;
|
||||
for(vi=S1.vert.begin();vi!=S1.vert.end();++vi)
|
||||
{
|
||||
error = AddSample((*vi).cP());
|
||||
|
@ -269,13 +269,13 @@ template <class MetroMesh>
|
|||
void Sampling<MetroMesh>::EdgeSampling()
|
||||
{
|
||||
// Edge sampling.
|
||||
typedef pair<typename MetroMesh::VertexPointer, typename MetroMesh::VertexPointer> pvv;
|
||||
vector< pvv > Edges;
|
||||
typedef std::pair<typename MetroMesh::VertexPointer, typename MetroMesh::VertexPointer> pvv;
|
||||
std::vector< pvv > Edges;
|
||||
|
||||
printf("Edge sampling\n");
|
||||
|
||||
// compute edge list.
|
||||
MetroMesh::FaceIterator fi;
|
||||
typename MetroMesh::FaceIterator fi;
|
||||
for(fi=S1.face.begin(); fi != S1.face.end(); fi++)
|
||||
for(int i=0; i<3; ++i)
|
||||
{
|
||||
|
@ -284,16 +284,16 @@ typedef pair<typename MetroMesh::VertexPointer, typename MetroMesh::VertexPointe
|
|||
swap(Edges.back().first, Edges.back().second);
|
||||
}
|
||||
sort(Edges.begin(), Edges.end());
|
||||
vector<pvv>::iterator edgeend = unique(Edges.begin(), Edges.end());
|
||||
typename std::vector< pvv>::iterator edgeend = unique(Edges.begin(), Edges.end());
|
||||
Edges.resize(edgeend-Edges.begin());
|
||||
|
||||
// sample edges.
|
||||
vector<pvv>::iterator ei;
|
||||
std::vector<pvv>::iterator ei;
|
||||
double n_samples_per_length_unit;
|
||||
double n_samples_decimal = 0.0;
|
||||
int cnt=0;
|
||||
if(Flags & FLAG_FACE_SAMPLING)
|
||||
n_samples_per_length_unit = sqrt(n_samples_per_area_unit);
|
||||
n_samples_per_length_unit = sqrt((double)n_samples_per_area_unit);
|
||||
else
|
||||
n_samples_per_length_unit = n_samples_per_area_unit;
|
||||
for(ei=Edges.begin(); ei!=Edges.end(); ++ei)
|
||||
|
@ -349,7 +349,7 @@ void Sampling<MetroMesh>::MontecarloFaceSampling()
|
|||
// Montecarlo sampling.
|
||||
int cnt = 0;
|
||||
double n_samples_decimal = 0.0;
|
||||
MetroMesh::FaceIterator fi;
|
||||
typename MetroMesh::FaceIterator fi;
|
||||
|
||||
srand(clock());
|
||||
// printf("Montecarlo face sampling\n");
|
||||
|
@ -425,7 +425,7 @@ void Sampling<MetroMesh>::SubdivFaceSampling()
|
|||
// Subdivision sampling.
|
||||
int cnt = 0, maxdepth;
|
||||
double n_samples_decimal = 0.0;
|
||||
MetroMesh::FaceIterator fi;
|
||||
typename MetroMesh::FaceIterator fi;
|
||||
|
||||
printf("Subdivision face sampling\n");
|
||||
for(fi=S1.face.begin(); fi != S1.face.end(); fi++)
|
||||
|
@ -436,7 +436,7 @@ void Sampling<MetroMesh>::SubdivFaceSampling()
|
|||
if(n_samples)
|
||||
{
|
||||
// face sampling.
|
||||
maxdepth = (int)log((double)n_samples)/log(2.0);
|
||||
maxdepth = ((int)(log((double)n_samples)/log(2.0)));
|
||||
n_samples = 0;
|
||||
FaceSubdiv((*fi).V(0)->cP(), (*fi).V(1)->cP(), (*fi).V(2)->cP(), maxdepth);
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ void Sampling<MetroMesh>::SimilarFaceSampling()
|
|||
// Similar Triangles sampling.
|
||||
int cnt = 0, n_samples_per_edge;
|
||||
double n_samples_decimal = 0.0;
|
||||
MetroMesh::FaceIterator fi;
|
||||
typename MetroMesh::FaceIterator fi;
|
||||
|
||||
printf("Similar Triangles face sampling\n");
|
||||
for(fi=S1.face.begin(); fi != S1.face.end(); fi++)
|
||||
|
@ -505,7 +505,7 @@ void Sampling<MetroMesh>::SimilarFaceSampling()
|
|||
template <class MetroMesh>
|
||||
void Sampling<MetroMesh>::Hausdorff()
|
||||
{
|
||||
Box3< MetroMesh::ScalarType> bbox;
|
||||
Box3< typename MetroMesh::ScalarType> bbox;
|
||||
|
||||
// set grid meshes.
|
||||
gS2.SetBBox(S2.bbox);
|
||||
|
@ -551,7 +551,7 @@ void Sampling<MetroMesh>::Hausdorff()
|
|||
// compute vertex colour
|
||||
if(Flags & FLAG_SAVE_ERROR_AS_COLOUR)
|
||||
{
|
||||
MetroMesh::VertexIterator vi;
|
||||
typename MetroMesh::VertexIterator vi;
|
||||
float error;
|
||||
int cnt = 0;
|
||||
for(vi=S1.vert.begin();vi!=S1.vert.end();++vi)
|
||||
|
|
Loading…
Reference in New Issue