Skip to content

Commit

Permalink
Warnings cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewencp committed Aug 8, 2012
1 parent 2f7af14 commit 393cbe3
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 110 deletions.
2 changes: 1 addition & 1 deletion externals/liboauthcpp
Submodule liboauthcpp updated 2 files
+5 −2 src/SHA1.cpp
+1 −1 src/liboauthcpp.cpp
36 changes: 18 additions & 18 deletions libmesh/plugins/common-filters/DeduplicationFilter.cpp
Expand Up @@ -52,7 +52,7 @@ bool comp(Vector3f point1, Vector3f point2) {
FilterDataPtr DeduplicationFilter::apply(FilterDataPtr input) {
for(FilterData::const_iterator md_it = input->begin(); md_it != input->end(); md_it++) {
VisualPtr vis = *md_it;

MeshdataPtr mesh( std::tr1::dynamic_pointer_cast<Meshdata>(vis) );
if (mesh) {
//normals are necessary, the filter might break without them....
Expand All @@ -62,22 +62,22 @@ FilterDataPtr DeduplicationFilter::apply(FilterDataPtr input) {
if(mesh->geometry.size() >= 2) {
//we sort the positions before hand so they're easier to use... but this may be unnecessary.
std::vector<std::vector<Vector3f> > sortedPositions;
for(int i = 0; i < mesh->geometry.size(); i++) {
for(uint32 i = 0; i < mesh->geometry.size(); i++) {
std::vector<Vector3f> v = mesh->geometry[i].positions;
std::sort(v.begin(), v.begin() + v.size(), comp);
sortedPositions.push_back(v);
}
//test if all of the points are exactly the same
//a better way (possibly) is to put it with the other major loop
//and just note whether every single point is the same as the loop runs
for(int i = 0; i < mesh->geometry.size(); i++) {
for(int j = i + 1; j < mesh->geometry.size(); j++) {
for(uint32 i = 0; i < mesh->geometry.size(); i++) {
for(uint32 j = i + 1; j < mesh->geometry.size(); j++) {
bool same = true;
//should switch to unordered_set
if(mesh->instances[i].materialBindingMap[mesh->geometry[i].primitives[0].materialId] !=
mesh->instances[j].materialBindingMap[mesh->geometry[j].primitives[0].materialId] &&
sortedPositions[i].size() == sortedPositions[j].size()) {
for(int k = 0; k < sortedPositions[i].size(); k++) {
for(uint32 k = 0; k < sortedPositions[i].size(); k++) {
if(sortedPositions[i][k] != sortedPositions[j][k]) same = false;
}
} else same = false;
Expand All @@ -89,52 +89,52 @@ FilterDataPtr DeduplicationFilter::apply(FilterDataPtr input) {
p.primitiveType = mesh->geometry[i].primitives[0].primitiveType;
mesh->geometry[i].primitives.push_back(p);

for(int k = 0; k < mesh->geometry[j].primitives[0].indices.size(); k++)
for(uint32 k = 0; k < mesh->geometry[j].primitives[0].indices.size(); k++)
mesh->geometry[i].primitives[mesh->geometry[i].primitives.size() - 1].indices.push_back(mesh->geometry[j].primitives[0].indices[k] + add);
for(int k = 0; k < mesh->geometry[j].positions.size(); k++)
for(uint32 k = 0; k < mesh->geometry[j].positions.size(); k++)
mesh->geometry[i].positions.push_back(mesh->geometry[j].positions[k]);
//materials
//materials
mesh->geometry[i].primitives[mesh->geometry[i].primitives.size() - 1].materialId = mesh->instances[i].materialBindingMap.size() + 1;

//submeshgeometry
mesh->geometry.erase(mesh->geometry.begin() + j);

//geometryinstance
mesh->instances[i].materialBindingMap[mesh->instances[i].materialBindingMap.size() + 1] = mesh->instances[j].materialBindingMap[1];

mesh->instances.erase(mesh->instances.begin() + j);
for(int k = j; k < mesh->instances.size(); k++)
for(uint32 k = j; k < mesh->instances.size(); k++)
mesh->instances[k].geometryIndex = k;

//sortedPositions
sortedPositions.erase(sortedPositions.begin() + j);


}
}
}

//then, we see if the geometries have similar points: if they do, they should be mixed
for(int i = 0; i < mesh->geometry.size(); i++) {
for(int j = i + 1; j < mesh->geometry.size(); j++) {
for(uint32 i = 0; i < mesh->geometry.size(); i++) {
for(uint32 j = i + 1; j < mesh->geometry.size(); j++) {
bool combine = false;
//we compare two of the geometries:
//but we do not proceed unless their materials are the same (we can assume only one primitive for now)
if(mesh->instances[i].materialBindingMap[mesh->geometry[i].primitives[0].materialId] ==
mesh->instances[j].materialBindingMap[mesh->geometry[j].primitives[0].materialId]) {
for(int k = 0; k < mesh->geometry[i].positions.size(); k++) {
for(int l = 0; l < mesh->geometry[j].positions.size(); l++) {
for(uint32 k = 0; k < mesh->geometry[i].positions.size(); k++) {
for(uint32 l = 0; l < mesh->geometry[j].positions.size(); l++) {
//positions have to be the same
if(mesh->geometry[i].positions[k] == mesh->geometry[j].positions[l])
combine = true;
}
}
//and mix them (if necessary) here
if(combine) {
for(int l = 0; l < mesh->geometry[j].primitives[0].indices.size(); l++) {
for(uint32 l = 0; l < mesh->geometry[j].primitives[0].indices.size(); l++) {
bool addPoint = true;
int pos = -1;
for(int k = 0; k < mesh->geometry[i].primitives[0].indices.size() && addPoint; k++) {
for(uint32 k = 0; k < mesh->geometry[i].primitives[0].indices.size() && addPoint; k++) {
if(mesh->geometry[i].positions[mesh->geometry[i].primitives[0].indices[k]] ==
mesh->geometry[j].positions[mesh->geometry[j].primitives[0].indices[l]] &&
mesh->geometry[i].normals[mesh->geometry[i].primitives[0].indices[k]] ==
Expand All @@ -156,7 +156,7 @@ FilterDataPtr DeduplicationFilter::apply(FilterDataPtr input) {
//proper clean up
mesh->geometry.erase(mesh->geometry.begin() + j);
mesh->instances.erase(mesh->instances.begin() + j);
for(int k = j; k < mesh->instances.size(); k++)
for(uint32 k = j; k < mesh->instances.size(); k++)
mesh->instances[k].geometryIndex = k;

j--;
Expand Down
68 changes: 34 additions & 34 deletions libmesh/plugins/ply/PlyModelSystem.cpp
Expand Up @@ -71,11 +71,11 @@ Mesh::VisualPtr PlyModelSystem::load(const Transfer::RemoteFileMetadata& metadat
ss >> s;

Mesh::MeshdataPtr mdp(new Mesh::Meshdata);

int state = FILLER;
int vertexNum = 0, faceNum = 0, edgeNum = 0;
std::vector<int> propV, propF, propE;

bool loop = true;
std::vector<String> file;
while(ss && loop) {
Expand Down Expand Up @@ -157,7 +157,7 @@ Mesh::VisualPtr PlyModelSystem::load(const Transfer::RemoteFileMetadata& metadat
int numTexCoords;
//obtain vertex data
for(int i = 0; i < vertexNum; i++) {
for(int j = 0; j < propV.size(); j++) {
for(uint32 j = 0; j < propV.size(); j++) {
ss >> temp;
switch(propV[j]) {
case X: vert[i][0] = temp; break;
Expand All @@ -174,7 +174,7 @@ Mesh::VisualPtr PlyModelSystem::load(const Transfer::RemoteFileMetadata& metadat
}
//obtain face data
for(int i = 0; i < faceNum; i++) {
for(int j = 0; j < propF.size(); j++) {
for(uint32 j = 0; j < propF.size(); j++) {
switch(propF[j]) {
case VI:
ss >> numIndices;
Expand All @@ -195,15 +195,15 @@ Mesh::VisualPtr PlyModelSystem::load(const Transfer::RemoteFileMetadata& metadat
ss >> tc[face[i][k]][0];
temp2 = tc[face[i][k]][1];
ss >> tc[face[i][k]][1];

if(file.size() == 1) {
if((tc[face[i][k]][0] != temp1 && temp1 != -1) &&
(tc[face[i][k]][1] != temp2 && temp2 != -1))
tc[face[i][k]][2] = file.size();
else
tc[face[i][k]][2] = 0;
}

}
if(file.size() > 1) {
int numTex;
Expand All @@ -228,7 +228,7 @@ Mesh::VisualPtr PlyModelSystem::load(const Transfer::RemoteFileMetadata& metadat
nod.parent = Mesh::NullNodeIndex;
mdp->nodes.push_back(nod);
mdp->rootNodes.push_back(0);

Mesh::SubMeshGeometry smg;

//make a primitive
Expand All @@ -241,7 +241,7 @@ Mesh::VisualPtr PlyModelSystem::load(const Transfer::RemoteFileMetadata& metadat
Mesh::GeometryInstance gi;
gi.geometryIndex = 0;
gi.parentNode = 0;

//color: currently just takes the average of the colors and sets
//the color of the figure to this average color
int sumRed = 0, sumGreen = 0, sumBlue = 0, sumAlpha = 0;
Expand Down Expand Up @@ -269,7 +269,7 @@ Mesh::VisualPtr PlyModelSystem::load(const Transfer::RemoteFileMetadata& metadat
mdp->geometry[0].primitives[0].indices.push_back(face[i][j]);
} else {
//for each next set of indices, we first see
//if a previous primitive has either shared an
//if a previous primitive has either shared an
//index or shared a point. If yes, we may add
//to the same primitive, or we may make a new
//submeshgeometry.
Expand All @@ -281,30 +281,30 @@ Mesh::VisualPtr PlyModelSystem::load(const Transfer::RemoteFileMetadata& metadat
int counterSMG = 0;
std::vector<int> hitSMG;
bool sameSMG = false;
while(counterSMG < mdp->geometry.size()) {
while(counterSMG < (int)mdp->geometry.size()) {
for(int j = 0; j < 3; j++) {
//iterate through the indices
for(int k = 0; k < mdp->geometry[counterSMG].primitives.size(); k++) {
for(int l = 0; l < mdp->geometry[counterSMG].primitives[k].indices.size(); l++) {
for(uint32 k = 0; k < mdp->geometry[counterSMG].primitives.size(); k++) {
for(uint32 l = 0; l < mdp->geometry[counterSMG].primitives[k].indices.size(); l++) {
//we must check if the index is the same and also if the texture is the same
//something is wrong here! reverseMap is creating new entries (and that shouldn't happen!)
if(reverseMap[counterSMG][mdp->geometry[counterSMG].primitives[k].indices[l]] == face[i][j] &&
((col[reverseMap[counterSMG][mdp->geometry[counterSMG].primitives[k].indices[l]]][1] == col[face[i][j]][1] &&
col[reverseMap[counterSMG][mdp->geometry[counterSMG].primitives[k].indices[l]]][2] == col[face[i][j]][2] &&
col[reverseMap[counterSMG][mdp->geometry[counterSMG].primitives[k].indices[l]]][3] == col[face[i][j]][3]) ||
(abs(tc[reverseMap[counterSMG][mdp->geometry[counterSMG].primitives[k].indices[l]]][2]) > file.size() &&
abs(tc[face[i][j]][2]) > file.size() && file.size() > 0))) {
(abs(tc[reverseMap[counterSMG][mdp->geometry[counterSMG].primitives[k].indices[l]]][2]) > (int)file.size() &&
abs(tc[face[i][j]][2]) > (int)file.size() && file.size() > 0))) {
sameSMG = true;
bool isThere = false;
for(int m = 0; m < hitSMG.size(); m++)
for(uint32 m = 0; m < hitSMG.size(); m++)
if(hitSMG[m] == counterSMG) isThere = true; //is there a better way of doing this?
if(!isThere) hitSMG.push_back(counterSMG);


}
}
}

}
counterSMG++;
}
Expand All @@ -313,13 +313,13 @@ Mesh::VisualPtr PlyModelSystem::load(const Transfer::RemoteFileMetadata& metadat
//if the point hit multiple SMG's, we will have to merge them before adding a point
while(hitSMG.size() > 1) {
//First, submeshgeometry
for(int j = 0; j < mdp->geometry[hitSMG[1]].primitives[0].indices.size(); j++) {//we loop through the indices of the smg to be destroyed
for(uint32 j = 0; j < mdp->geometry[hitSMG[1]].primitives[0].indices.size(); j++) {//we loop through the indices of the smg to be destroyed
int ind = reverseMap[hitSMG[0]].size(); //index for increasing the reverseMap size...
Vector3f point = Vector3f(vert[reverseMap[hitSMG[1]][mdp->geometry[hitSMG[1]].primitives[0].indices[j]]][0], //here's a point from the smg to be transferred, at location j
vert[reverseMap[hitSMG[1]][mdp->geometry[hitSMG[1]].primitives[0].indices[j]]][1],
vert[reverseMap[hitSMG[1]][mdp->geometry[hitSMG[1]].primitives[0].indices[j]]][2]);
bool addPoint = true;
for(int k = 0; k < mdp->geometry[hitSMG[0]].positions.size() && addPoint; k++) { //we loop through the other points in the smg to be stuffed
for(uint32 k = 0; k < mdp->geometry[hitSMG[0]].positions.size() && addPoint; k++) { //we loop through the other points in the smg to be stuffed
if(point.x == mdp->geometry[hitSMG[0]].positions[k].x && //and try to see if there is a clone. if there is a clone,
point.y == mdp->geometry[hitSMG[0]].positions[k].y && //we don't add a point? but if there is, we do add a point?
point.z == mdp->geometry[hitSMG[0]].positions[k].z)
Expand All @@ -329,20 +329,20 @@ Mesh::VisualPtr PlyModelSystem::load(const Transfer::RemoteFileMetadata& metadat
mdp->geometry[hitSMG[0]].positions.push_back(point); //since we need to add a point, we store the point in the smg...
indexMap[reverseMap[hitSMG[1]][mdp->geometry[hitSMG[1]].primitives[0].indices[j]]] = ind; //we map the old point to the new point...
reverseMap[hitSMG[0]][ind] = reverseMap[hitSMG[1]][mdp->geometry[hitSMG[1]].primitives[0].indices[j]]; //and map the new point in reverse to the old!
}
}
mdp->geometry[hitSMG[0]].primitives[0].indices.push_back(indexMap[reverseMap[hitSMG[1]][mdp->geometry[hitSMG[1]].primitives[0].indices[j]]]);
}
//proper deletions
mdp->geometry.erase(mdp->geometry.begin() + hitSMG[1]);
//then, geometryInstance
mdp->instances.erase(mdp->instances.begin() + hitSMG[1]);
for(int j = hitSMG[1]; j < mdp->instances.size(); j++)
for(uint32 j = hitSMG[1]; j < mdp->instances.size(); j++)
mdp->instances[j].geometryIndex = j;
//also, reverseMap
reverseMap.erase(reverseMap.begin() + hitSMG[1]);
//finally, hitSMG
hitSMG.erase(hitSMG.begin() + 1);
for(int i = 1; i < hitSMG.size(); i++) hitSMG[i]--;//since we removed a hitSMG we have to lower the index of the other hits by one
for(uint32 i = 1; i < hitSMG.size(); i++) hitSMG[i]--;//since we removed a hitSMG we have to lower the index of the other hits by one
}
for(int j = 0; j < 3; j++) {
//we put the point in
Expand All @@ -356,7 +356,7 @@ Mesh::VisualPtr PlyModelSystem::load(const Transfer::RemoteFileMetadata& metadat
}

mdp->geometry[hitSMG[0]].primitives[0].indices.push_back(indexMap[face[i][j]]);

}
} else {
//otherwise, we'll make a new submeshgeometry/geometry set
Expand All @@ -378,18 +378,18 @@ Mesh::VisualPtr PlyModelSystem::load(const Transfer::RemoteFileMetadata& metadat
}
}
}

}


//int fileCounter = 0;
int mapCounter = 0;
for(int i = 0; i < mdp->geometry.size(); i++) {
for(uint32 i = 0; i < mdp->geometry.size(); i++) {
//one texture set for the geometry
if(tc[0][0] > 0) {
Mesh::SubMeshGeometry::TextureSet ts;
ts.stride = 2;
for(int j = 0; j < mdp->geometry[i].positions.size(); j++) {
for(uint32 j = 0; j < mdp->geometry[i].positions.size(); j++) {
for(int k = 0; k < 2; k++) {
ts.uvs.push_back(tc[reverseMap[i][j]][k]);
}
Expand All @@ -400,7 +400,7 @@ Mesh::VisualPtr PlyModelSystem::load(const Transfer::RemoteFileMetadata& metadat
if(faceNum > 0) {
Mesh::MaterialEffectInfo::Texture t;
bool hasTexture = false;
for(int j = 0; j < mdp->geometry[i].primitives[0].indices.size() && !hasTexture; j++) {
for(uint32 j = 0; j < mdp->geometry[i].primitives[0].indices.size() && !hasTexture; j++) {
if((abs(tc[reverseMap[i][mdp->geometry[i].primitives[0].indices[j]]][0]) > .001 &&
abs(tc[reverseMap[i][mdp->geometry[i].primitives[0].indices[j]]][0]) < INT_MAX) ||
(abs(tc[reverseMap[i][mdp->geometry[i].primitives[0].indices[j]]][1]) > .001 &&
Expand All @@ -410,13 +410,13 @@ Mesh::VisualPtr PlyModelSystem::load(const Transfer::RemoteFileMetadata& metadat
//if the texCoords are all almost zero (or are infinite), then this is not a truly texturized geometry

if(hasTexture && tc[reverseMap[i][mdp->geometry[i].primitives[0].indices[0]]][2] >= 0
&& tc[reverseMap[i][mdp->geometry[i].primitives[0].indices[0]]][2] < file.size()) {
&& tc[reverseMap[i][mdp->geometry[i].primitives[0].indices[0]]][2] < file.size()) {

//we add the texture and typical values
mei.shininess = -128;
mei.reflectivity = -1;
bool newFile = true;
for(int l = 0; l < mdp->textures.size(); l++)
for(uint32 l = 0; l < mdp->textures.size(); l++)
if(mdp->textures[l] == file[tc[reverseMap[i][mdp->geometry[i].primitives[0].indices[0]]][2]])
newFile = false;
if(newFile)
Expand All @@ -438,7 +438,7 @@ Mesh::VisualPtr PlyModelSystem::load(const Transfer::RemoteFileMetadata& metadat
} else {
//we add a color
Vector4f c;
if(mdp->geometry[i].primitives[0].primitiveType == Mesh::SubMeshGeometry::Primitive::TRIANGLES &&
if(mdp->geometry[i].primitives[0].primitiveType == Mesh::SubMeshGeometry::Primitive::TRIANGLES &&
col[reverseMap[i][mdp->geometry[i].primitives[0].indices[0]]][0] >= 0) { //we might need a better check here if we get certain files
c = Vector4f(col[reverseMap[i][mdp->geometry[i].primitives[0].indices[0]]][0] / 255.0,
col[reverseMap[i][mdp->geometry[i].primitives[0].indices[0]]][1] / 255.0,
Expand All @@ -454,14 +454,14 @@ Mesh::VisualPtr PlyModelSystem::load(const Transfer::RemoteFileMetadata& metadat
mei.textures.push_back(t);
bool addMat = true;
int matPos = -1;
for(int j = 0; j < mdp->materials.size(); j++)
for(uint32 j = 0; j < mdp->materials.size(); j++)
if(mdp->materials[j] == mei) {
addMat = false;
matPos = j;
}
mdp->geometry[i].primitives[0].materialId = 1;
//if there is not, we add it, otherwise we do not
if(addMat) {
if(addMat) {
mdp->instances[i].materialBindingMap[mdp->geometry[i].primitives[0].materialId] = mapCounter;
mapCounter++;
mdp->materials.push_back(mei);
Expand All @@ -470,7 +470,7 @@ Mesh::VisualPtr PlyModelSystem::load(const Transfer::RemoteFileMetadata& metadat

} else mdp->materials.push_back(mei);
}

delete vert;
delete col;
delete face;
Expand All @@ -496,4 +496,4 @@ bool PlyModelSystem::convertVisual(const Mesh::VisualPtr& visual, const String&
NOT_IMPLEMENTED(mesh-ply);
return false;
}
} // namespace Sirikata
} // namespace Sirikata
2 changes: 1 addition & 1 deletion test/unit/libcore/StrandTest.hpp
Expand Up @@ -35,7 +35,7 @@ class StrandTest : public CxxTest::TestSuite {
if (work != NULL) {
delete work; work = NULL;
}
for(int i = 0; i < threads.size(); i++) {
for(uint32 i = 0; i < threads.size(); i++) {
threads[i]->join();
}
threads.clear();
Expand Down

0 comments on commit 393cbe3

Please sign in to comment.