From d6aec85fb0e391b2fccbb9d0e3f0b67cf9d779c3 Mon Sep 17 00:00:00 2001 From: ganovelli Date: Tue, 11 May 2004 14:39:17 +0000 Subject: [PATCH] general comment for metro files: modification to comply g++ compiler --- apps/metro/mesh_type.h | 6 ++-- apps/metro/metro.cpp | 24 ++++++++------- apps/metro/min_dist_point.h | 14 +++++---- apps/metro/sampling.h | 60 ++++++++++++++++++------------------- 4 files changed, 54 insertions(+), 50 deletions(-) diff --git a/apps/metro/mesh_type.h b/apps/metro/mesh_type.h index 9354d278..3f18f9f9 100644 --- a/apps/metro/mesh_type.h +++ b/apps/metro/mesh_type.h @@ -34,7 +34,7 @@ //#include #include #include -#include +#include #include @@ -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::F(j);} - }; +class CFace : public FaceRTFMFN< CVertex,MyEdge,CFace > {}; class CMesh : public tri::TriMesh< vector, vector > {}; // ----------------------------------------------------------------------------------------------- diff --git a/apps/metro/metro.cpp b/apps/metro/metro.cpp index 0ec2ec57..c21991b4 100644 --- a/apps/metro/metro.cpp +++ b/apps/metro/metro.cpp @@ -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::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::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; } // ----------------------------------------------------------------------------------------------- diff --git a/apps/metro/min_dist_point.h b/apps/metro/min_dist_point.h index f50a9ea8..26f2d181 100644 --- a/apps/metro/min_dist_point.h +++ b/apps/metro/min_dist_point.h @@ -42,8 +42,12 @@ #include #include +#include #include #include +#include + + using namespace vcg; @@ -68,7 +72,7 @@ void MinDistPoint( MESH & mesh, const Point3 & p, GRID & gr, SCALAR & md typedef Box3 Box3x; if(!gr.bbox.IsIn(p)) return; - typedef GridStaticObj::Link A2UGridLink; + typedef typename GridStaticPtr::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 & 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 & 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 & 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 & p, GRID & gr, SCALAR & md Point3 ip; MinDistPoint(mesh,p,gr,mdist,normf,bestq,f,ip); } -#endif \ No newline at end of file +#endif diff --git a/apps/metro/sampling.h b/apps/metro/sampling.h index a89a28ab..aba486d4 100644 --- a/apps/metro/sampling.h +++ b/apps/metro/sampling.h @@ -36,7 +36,7 @@ //#include #include #include -#include +#include using namespace vcg; // ----------------------------------------------------------------------------------------------- @@ -67,7 +67,7 @@ template class Sampling { private: - typedef GridStaticObj< typename MetroMesh::FaceContainer > MetroMeshGrid; + typedef GridStaticPtr< typename MetroMesh::FaceContainer > MetroMeshGrid; typedef Point3 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::Sampling(MetroMesh &_s1, MetroMesh &_s2):S1(_s1),S2(_s2) // set sampling parameters template -void Sampling::SetSamplesTarget(int _n_samp) +void Sampling::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 void Sampling::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::SetSamplesPerAreaUnit(double _n_samp) template inline double Sampling::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::ComputeMeshArea(MetroMesh & mesh) template float Sampling::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::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 void Sampling::EdgeSampling() { // Edge sampling. -typedef pair pvv; - vector< pvv > Edges; + typedef std::pair 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::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::iterator ei; + std::vector::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::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::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::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::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::SimilarFaceSampling() template void Sampling::Hausdorff() { - Box3< MetroMesh::ScalarType> bbox; + Box3< typename MetroMesh::ScalarType> bbox; // set grid meshes. gS2.SetBBox(S2.bbox); @@ -551,7 +551,7 @@ void Sampling::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)