many gcc compiling issues

This commit is contained in:
Paolo Cignoni 2006-11-07 17:22:53 +00:00
parent e2733d55df
commit 642158fc32
6 changed files with 59 additions and 44 deletions

View File

@ -78,13 +78,26 @@ namespace vcg
typedef OBJECT_TYPE* ObjectPointer; typedef OBJECT_TYPE* ObjectPointer;
typedef std::pair< ObjectPointer, int > hPair; typedef std::pair< ObjectPointer, int > hPair;
#ifdef __GNUC__
typedef typename STDEXT::hash_map< /*ObjectPointer*/void*, int >::iterator hIterator; struct SimpleObjHashFunc{
inline size_t operator ()(const ObjectPointer &p) const {return size_t(p);}
};
#ifdef _MSC_VER
STDEXT::hash_map< OBJECT_TYPE*, int > inserted_objects;
typedef typename STDEXT::hash_map< ObjectPointer, int >::iterator hIterator;
#else #else
typedef typename STDEXT::hash_map< ObjectPointer, int >::iterator hIterator; STDEXT::hash_map< OBJECT_TYPE*, int, SimpleObjHashFunc > inserted_objects;
typedef typename STDEXT::hash_map< ObjectPointer, int, SimpleObjHashFunc >::iterator hIterator;
#endif #endif
typedef std::pair< hIterator, bool > hInsertResult; typedef std::pair< hIterator, bool > hInsertResult;
public: public:
/*! /*!
* Default constructor * Default constructor
@ -146,11 +159,6 @@ namespace vcg
} }
protected: protected:
#ifdef __GNUC__
STDEXT::hash_map< void*, int > inserted_objects;
#else
STDEXT::hash_map< OBJECT_TYPE*, int > inserted_objects;
#endif
std::vector< DisjointSetNode > nodes; std::vector< DisjointSetNode > nodes;
}; };
};// end of namespace vcg };// end of namespace vcg

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.6 2006/11/07 15:13:57 zifnab1974
Necessary changes for compilation with gcc 3.4.6. Especially the hash function is a problem
Revision 1.5 2006/11/07 11:29:24 cignoni Revision 1.5 2006/11/07 11:29:24 cignoni
Corrected some errors in the reflections Has*** functions Corrected some errors in the reflections Has*** functions
@ -277,11 +280,11 @@ public:
namespace tri namespace tri
{ {
template < class VertType, class FaceContainerType > template < class VertexType, class FaceContainerType >
bool HasPerVertexQuality (const TriMesh < vert::vector_ocf< VertType > , FaceContainerType > & m) bool HasPerVertexQuality (const TriMesh < vert::vector_ocf< VertexType > , FaceContainerType > & m)
{ {
if(VertType::HasQualityOcf()) return m.vert.IsQualityEnabled(); if(VertexType::HasQualityOcf()) return m.vert.IsQualityEnabled();
else return VertType::HasQuality(); else return VertexType::HasQuality();
} }
} }

View File

@ -171,7 +171,7 @@ namespace vcg
// for each vertex *iter, compute the centroid as avarege of the k-nearest vertices of *iter // for each vertex *iter, compute the centroid as avarege of the k-nearest vertices of *iter
Plane *plane = &tangent_planes[ std::distance(begin, iter) ]; Plane *plane = &tangent_planes[ std::distance(begin, iter) ];
for (int n=0; n<k; n++) for (unsigned int n=0; n<k; n++)
plane->center += nearest_points[n]; plane->center += nearest_points[n];
plane->center /= float(k); plane->center /= float(k);
@ -179,7 +179,7 @@ namespace vcg
MatrixType covariance_matrix; MatrixType covariance_matrix;
CoordType diff; CoordType diff;
covariance_matrix.SetZero(); covariance_matrix.SetZero();
for (int n=0; n<k; n++) for (unsigned int n=0; n<k; n++)
{ {
diff = nearest_points[n] - plane->center; diff = nearest_points[n] - plane->center;
for (int i=0; i<3; i++) for (int i=0; i<3; i++)

View File

@ -101,17 +101,17 @@ private:
if(mask & vcg::tri::io::Mask::IOM_VERTCOLOR) if(mask & vcg::tri::io::Mask::IOM_VERTCOLOR)
arrc.reserve(5 * 4 * m.vert.size()); arrc.reserve(5 * 4 * m.vert.size());
int nvert = 0; int nvert = 0;
for(SaveMeshType::VertexIterator it = m.vert.begin();it != m.vert.end();++it) for(typename SaveMeshType::VertexIterator it = m.vert.begin();it != m.vert.end();++it)
{ {
if (!(it->IsD())) if (!(it->IsD()))
{ {
arrp.append(QString::number(it->P().X()).append(" ").append(QString::number(it->P().Y())).append(" ").append(QString::number(it->P().Z())).append(" ")); arrp.append(QString::number(float(it->P().X())).append(" ").append(QString::number(float(it->P().Y()))).append(" ").append(QString::number(float(it->P().Z()))).append(" "));
if(mask & vcg::tri::io::Mask::IOM_VERTNORMAL) if(mask & vcg::tri::io::Mask::IOM_VERTNORMAL)
arrn.append(QString::number(it->N().X()).append(" ").append(QString::number(it->N().Y())).append(" ").append(QString::number(it->N().Z())).append(" ")); arrn.append(QString::number(float(it->N().X())).append(" ").append(QString::number(float(it->N().Y()))).append(" ").append(QString::number(float(it->N().Z()))).append(" "));
if(mask & vcg::tri::io::Mask::IOM_VERTTEXCOORD) if(mask & vcg::tri::io::Mask::IOM_VERTTEXCOORD)
arrt.append(QString::number(it->T().u()).append(" ").append(QString::number(it->T().v())).append(" ")); arrt.append(QString::number(float(it->T().u())).append(" ").append(QString::number(float(it->T().v()))).append(" "));
if(mask & vcg::tri::io::Mask::IOM_VERTCOLOR) if(mask & vcg::tri::io::Mask::IOM_VERTCOLOR)
arrc.append(QString::number(it->C().X()).append(" ").append(QString::number(it->C().Y())).append(" ").append(QString::number(it->C().Z())).append(" ").append(QString::number(it->C().W())).append(" ")); arrc.append(QString::number(float(it->C().X())).append(" ").append(QString::number(float(it->C().Y()))).append(" ").append(QString::number(float(it->C().Z()))).append(" ").append(QString::number(float(it->C().W()))).append(" "));
++nvert; ++nvert;
} }
} }
@ -174,7 +174,7 @@ private:
triangles_tess.reserve(nattr * 3 * 10 * m.face.size()); triangles_tess.reserve(nattr * 3 * 10 * m.face.size());
int wn = 0; int wn = 0;
int wt = 0; int wt = 0;
for(SaveMeshType::FaceIterator itf = m.face.begin();itf != m.face.end();++itf) for(typename SaveMeshType::FaceIterator itf = m.face.begin();itf != m.face.end();++itf)
{ {
if (!(itf->IsD())) if (!(itf->IsD()))
{ {
@ -188,7 +188,7 @@ private:
{ {
triangles_tess.append(" ").append(QString::number(wn)); triangles_tess.append(" ").append(QString::number(wn));
++wn; ++wn;
triangles_wn.append(QString::number((*itf).WN(ii).X()).append(" ").append(QString::number((*itf).WN(ii).Y())).append(" ").append(QString::number((*itf).WN(ii).Z())).append(" ")); triangles_wn.append(QString::number(float((*itf).WN(ii).X())).append(" ").append(QString::number(float((*itf).WN(ii).Y()))).append(" ").append(QString::number(float((*itf).WN(ii).Z()))).append(" "));
} }
if (mask & MeshModel::IOM_WEDGTEXCOORD) if (mask & MeshModel::IOM_WEDGTEXCOORD)
@ -335,7 +335,7 @@ public:
/*QDomElement mshnode; /*QDomElement mshnode;
mshnode.setTagName("mesh");*/ mshnode.setTagName("mesh");*/
removeChildNode(geolib.at(0),"geometry","id","vcg-mesh-lib"); removeChildNode(geolib.at(0),QString("geometry"),QString("id"),QString("vcg-mesh-lib"));
QDomElement geonode = info->doc->createElement("geometry"); QDomElement geonode = info->doc->createElement("geometry");
geonode.setAttribute("id","vcg-mesh-lib"); geonode.setAttribute("id","vcg-mesh-lib");
geonode.setAttribute("name","vcg-mesh"); geonode.setAttribute("name","vcg-mesh");
@ -349,7 +349,7 @@ public:
} }
else else
{ {
removeChildNode(scenelst,"instance_visual_scene"); removeChildNodeList(scenelst,QString("instance_visual_scene"));
for(int vsscn = 0;vsscn < scenelst.size();++vsscn) for(int vsscn = 0;vsscn < scenelst.size();++vsscn)
{ {
QString url = scenelst.at(vsscn).toElement().attribute("url"); QString url = scenelst.at(vsscn).toElement().attribute("url");
@ -361,7 +361,7 @@ public:
int vsscene_size = vsscene.size(); int vsscene_size = vsscene.size();
assert(vsscene.size() == 1); assert(vsscene.size() == 1);
removeChildNode(vsscene,"visual_scene","id","vcg-scene-node"); removeChildNodeList(vsscene,QString("visual_scene"),QString("id"),QString("vcg-scene-node"));
QDomElement vslnode = info->doc->createElement("visual_scene"); QDomElement vslnode = info->doc->createElement("visual_scene");
vslnode.setAttribute("id","vcg-scene-node"); vslnode.setAttribute("id","vcg-scene-node");
vslnode.setAttribute("name","vcg-untitled"); vslnode.setAttribute("name","vcg-untitled");
@ -380,7 +380,7 @@ public:
QDomNodeList geolib = info->doc->elementsByTagName("library_geometries"); QDomNodeList geolib = info->doc->elementsByTagName("library_geometries");
assert(geolib.size() == 1); assert(geolib.size() == 1);
removeChildNode(geolib.at(0),"geometry","id","vcg-mesh-lib"); removeChildNode(geolib.at(0),QString("geometry"),QString("id"),QString("vcg-mesh-lib"));
QDomElement geonode = info->doc->createElement("geometry"); QDomElement geonode = info->doc->createElement("geometry");
geonode.setAttribute("id","vcg-mesh-lib"); geonode.setAttribute("id","vcg-mesh-lib");
geonode.setAttribute("name","vcg-mesh"); geonode.setAttribute("name","vcg-mesh");

View File

@ -68,7 +68,8 @@ namespace io {
if (!srcnodenorm.isNull()) if (!srcnodenorm.isNull())
{ {
assert((ii * 3 < geosrcvertnorm.size()) && (ii * 3 + 1 < geosrcvertnorm.size()) && (ii * 3 + 2 < geosrcvertnorm.size())); assert((ii * 3 < geosrcvertnorm.size()) && (ii * 3 + 1 < geosrcvertnorm.size()) && (ii * 3 + 2 < geosrcvertnorm.size()));
vcg::Matrix44f intr44 = vcg::Transpose(vcg::Inverse(t)); vcg::Matrix44f intr44 = vcg::Inverse(t);
vcg::Transpose(intr44);
Matrix33f intr33; Matrix33f intr33;
for(unsigned int rr = 0; rr < 2; ++rr) for(unsigned int rr = 0; rr < 2; ++rr)
{ {
@ -276,7 +277,7 @@ namespace io {
info->doc = doc; info->doc = doc;
//GetTexture(*(info->doc),inf); //GetTexture(*(info->doc),inf);
QDomNodeList& scenes = info->doc->elementsByTagName("scene"); QDomNodeList scenes = info->doc->elementsByTagName("scene");
int scn_size = scenes.size(); int scn_size = scenes.size();
if (scn_size == 0) if (scn_size == 0)
return E_NO3DSCENE; return E_NO3DSCENE;
@ -286,7 +287,7 @@ namespace io {
//for each scene in COLLADA FILE //for each scene in COLLADA FILE
for(int scn = 0;scn < scn_size;++scn) for(int scn = 0;scn < scn_size;++scn)
{ {
QDomNodeList& instscenes = scenes.at(scn).toElement().elementsByTagName("instance_visual_scene"); QDomNodeList instscenes = scenes.at(scn).toElement().elementsByTagName("instance_visual_scene");
int instscn_size = instscenes.size(); int instscn_size = instscenes.size();
if (instscn_size == 0) if (instscn_size == 0)
return E_INCOMPATIBLECOLLADA141FORMAT; return E_INCOMPATIBLECOLLADA141FORMAT;
@ -302,19 +303,19 @@ namespace io {
return E_UNREFERENCEBLEDCOLLADAATTRIBUTE; return E_UNREFERENCEBLEDCOLLADAATTRIBUTE;
//for each node in the libscn_url visual scene //for each node in the libscn_url visual scene
QDomNodeList& visscn_child = visscn.childNodes(); QDomNodeList visscn_child = visscn.childNodes();
//for each direct child of a libscn_url visual scene find if there is some geometry instance //for each direct child of a libscn_url visual scene find if there is some geometry instance
int problem = 0; int problem = 0;
for(int chdind = 0; chdind < visscn_child.size();++chdind) for(int chdind = 0; chdind < visscn_child.size();++chdind)
{ {
QDomNodeList& geoinst = visscn_child.at(chdind).toElement().elementsByTagName("instance_geometry"); QDomNodeList geoinst = visscn_child.at(chdind).toElement().elementsByTagName("instance_geometry");
int geoinst_size = geoinst.size(); int geoinst_size = geoinst.size();
if (geoinst_size != 0) if (geoinst_size != 0)
{ {
geoinst_found |= true; geoinst_found |= true;
QDomNodeList& geolib = info->doc->elementsByTagName("library_geometries"); QDomNodeList geolib = info->doc->elementsByTagName("library_geometries");
int geolib_size = geolib.size(); int geolib_size = geolib.size();
assert(geolib_size == 1); assert(geolib_size == 1);
//!!!!!!!!!!!!!!!!!here will be the code for geometry transformations!!!!!!!!!!!!!!!!!!!!!! //!!!!!!!!!!!!!!!!!here will be the code for geometry transformations!!!!!!!!!!!!!!!!!!!!!!
@ -340,10 +341,10 @@ namespace io {
if (!geoinst_found) if (!geoinst_found)
{ {
QDomNodeList& geolib = info->doc->elementsByTagName("library_geometries"); QDomNodeList geolib = info->doc->elementsByTagName("library_geometries");
int geolib_size = geolib.size(); int geolib_size = geolib.size();
assert(geolib_size == 1); assert(geolib_size == 1);
QDomNodeList& geochild = geolib.at(0).childNodes(); QDomNodeList geochild = geolib.at(0).childNodes();
int geochild_size = geochild.size(); int geochild_size = geochild.size();
int problem = 0; int problem = 0;
for(int chd = 0;chd < geochild_size;++chd) for(int chd = 0;chd < geochild_size;++chd)
@ -385,7 +386,7 @@ namespace io {
info->doc = doc; info->doc = doc;
GetTexture(*(info->doc),inf); GetTexture(*(info->doc),inf);
QDomNodeList& scenes = info->doc->elementsByTagName("scene"); QDomNodeList scenes = info->doc->elementsByTagName("scene");
int scn_size = scenes.size(); int scn_size = scenes.size();
@ -394,7 +395,7 @@ namespace io {
//for each scene in COLLADA FILE //for each scene in COLLADA FILE
for(int scn = 0;scn < scn_size;++scn) for(int scn = 0;scn < scn_size;++scn)
{ {
QDomNodeList& instscenes = scenes.at(scn).toElement().elementsByTagName("instance_visual_scene"); QDomNodeList instscenes = scenes.at(scn).toElement().elementsByTagName("instance_visual_scene");
int instscn_size = instscenes.size(); int instscn_size = instscenes.size();
if (instscn_size == 0) if (instscn_size == 0)
return false; return false;
@ -410,19 +411,21 @@ namespace io {
return false; return false;
//for each node in the libscn_url visual scene //for each node in the libscn_url visual scene
QDomNodeList& visscn_child = visscn.childNodes(); //QDomNodeList& visscn_child = visscn.childNodes();
QDomNodeList visscn_child = visscn.childNodes();
//for each direct child of a libscn_url visual scene find if there is some geometry instance //for each direct child of a libscn_url visual scene find if there is some geometry instance
int problem = 0; int problem = 0;
for(int chdind = 0; chdind < visscn_child.size();++chdind) for(int chdind = 0; chdind < visscn_child.size();++chdind)
{ {
QDomNodeList& geoinst = visscn_child.at(chdind).toElement().elementsByTagName("instance_geometry"); //QDomNodeList& geoinst = visscn_child.at(chdind).toElement().elementsByTagName("instance_geometry");
QDomNodeList geoinst = visscn_child.at(chdind).toElement().elementsByTagName("instance_geometry");
int geoinst_size = geoinst.size(); int geoinst_size = geoinst.size();
if (geoinst_size != 0) if (geoinst_size != 0)
{ {
geoinst_found |= true; geoinst_found |= true;
QDomNodeList& geolib = info->doc->elementsByTagName("library_geometries"); QDomNodeList geolib = info->doc->elementsByTagName("library_geometries");
int geolib_size = geolib.size(); int geolib_size = geolib.size();
assert(geolib_size == 1); assert(geolib_size == 1);
//!!!!!!!!!!!!!!!!!here will be the code for geometry transformations!!!!!!!!!!!!!!!!!!!!!! //!!!!!!!!!!!!!!!!!here will be the code for geometry transformations!!!!!!!!!!!!!!!!!!!!!!
@ -480,10 +483,10 @@ namespace io {
if (!geoinst_found) if (!geoinst_found)
{ {
QDomNodeList& geolib = info->doc->elementsByTagName("library_geometries"); QDomNodeList geolib = info->doc->elementsByTagName("library_geometries");
int geolib_size = geolib.size(); int geolib_size = geolib.size();
assert(geolib_size == 1); assert(geolib_size == 1);
QDomNodeList& geochild = geolib.at(0).toElement().elementsByTagName("geometry"); QDomNodeList geochild = geolib.at(0).toElement().elementsByTagName("geometry");
//!!!!!!!!!!!!!!!!!here will be the code for geometry transformations!!!!!!!!!!!!!!!!!!!!!! //!!!!!!!!!!!!!!!!!here will be the code for geometry transformations!!!!!!!!!!!!!!!!!!!!!!
info->numvert = 0; info->numvert = 0;
info->numface = 0; info->numface = 0;

View File

@ -161,7 +161,7 @@ namespace io {
} }
inline static bool removeChildNode(QDomNodeList& nodelst,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "") inline static bool removeChildNodeList(QDomNodeList& nodelst,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "")
{ {
for(int jj = 0;jj < nodelst.size();++jj) for(int jj = 0;jj < nodelst.size();++jj)
{ {
@ -170,12 +170,13 @@ namespace io {
return true; return true;
} }
inline static bool removeChildNode(QDomNode& node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "") /* inline static bool removeChildNode(QDomNode& node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "")
{ {
return removeChildNode((QDomDocument&) node.toElement(),tag,attribname,attribvalue); return removeChildNode((QDomDocument&) node.toElement(),tag,attribname,attribvalue);
} }*/
inline static bool removeChildNode(QDomDocument& node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "") //inline static bool removeChildNode(QDomDocument& node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "")
inline static bool removeChildNode(QDomNode node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "")
{ {
QDomNodeList clst = node.childNodes(); QDomNodeList clst = node.childNodes();
for(int ii = 0;ii < clst.size();++ii) for(int ii = 0;ii < clst.size();++ii)