From 75da5465f79a35ff2f21ef0cc6c2aef3a7bb8bd4 Mon Sep 17 00:00:00 2001 From: Matteo Dellepiane matteodelle Date: Wed, 12 Oct 2011 18:27:02 +0000 Subject: [PATCH] dellepiane: mutualglobal chossing the right arc, debugging --- .../filter_mutualglobal.cpp | 97 +++++++++++-------- 1 file changed, 57 insertions(+), 40 deletions(-) diff --git a/src/meshlabplugins/filter_mutualglobal/filter_mutualglobal.cpp b/src/meshlabplugins/filter_mutualglobal/filter_mutualglobal.cpp index bf3e085e7..a28e28f58 100644 --- a/src/meshlabplugins/filter_mutualglobal/filter_mutualglobal.cpp +++ b/src/meshlabplugins/filter_mutualglobal/filter_mutualglobal.cpp @@ -166,8 +166,10 @@ bool FilterMutualInfoPlugin::applyFilter(QAction */*filter*/, MeshDocument &md, std::vector Graphs; Graphs=buildGraph(md); + Log(0, "BuildGraph completed"); AlignGlobal(md, Graphs); + Log(0, "AlignGlobal completed"); } //for(int i = 0; i < Graphs.size(); i++) @@ -178,6 +180,7 @@ bool FilterMutualInfoPlugin::applyFilter(QAction */*filter*/, MeshDocument &md, //Graphs.clear(); this->glContext->doneCurrent(); + Log(0, "Done!"); return true; @@ -489,6 +492,7 @@ std::vector FilterMutualInfoPlugin::buildGraph(MeshDocument &md) std::vector allArcs; allArcs=CalcPairs(md); + Log(0, "Calcpairs completed"); return CreateGraphs(md, allArcs); } @@ -631,6 +635,7 @@ std::vector FilterMutualInfoPlugin::CreateGraphs(MeshDocument &md, std int numNodes=md.rasterList.size(); bool* assigned=new bool(); int* grNum=new int(); + Log(0, "Tuttok1"); for (int s=0; s FilterMutualInfoPlugin::CreateGraphs(MeshDocument &md, std int totGr=1; bool done=false; int totNodes=0; + Log(0, "Tuttok2"); while (!done) { for (int i=0; i FilterMutualInfoPlugin::CreateGraphs(MeshDocument &md, std done=true; else totGr++; } - + Log(0, "Tuttok3"); for (int i=1; i FilterMutualInfoPlugin::CreateGraphs(MeshDocument &md, std if(arcs[k].imageId==j) { mut+=arcs[k].mutual*arcs[k].area; + are+=arcs[k].area; n.arcs.push_back(arcs[k]); + } } - n.avMut=mut/n.arcs.size(); + n.avMut=mut/are; std::sort(n.arcs.begin(), n.arcs.end(), ordering()); graph.nodes.push_back(n); + Log(0, "Node %d of %d: avMut %3.2f, arch %d",j,numNodes, n.avMut, n.arcs.size()); } } Gr.push_back(graph); } - + Log(0, "Tuttok5"); Log(0, "Tot nodes %d, SubGraphs %d",numNodes,totGr); return Gr; @@ -707,13 +717,18 @@ bool FilterMutualInfoPlugin::AlignGlobal(MeshDocument &md, std::vector { for (int i=0; icm; + + vcg::Point3f *vertices = new vcg::Point3f[align.mesh->vn]; + vcg::Point3f *normals = new vcg::Point3f[align.mesh->vn]; + vcg::Color4b *colors = new vcg::Color4b[align.mesh->vn]; + unsigned int *indices = new unsigned int[align.mesh->fn*3]; + + for(int i = 0; i < align.mesh->vn; i++) { + vertices[i] = align.mesh->vert[i].P(); + normals[i] = align.mesh->vert[i].N(); + colors[i] = align.mesh->vert[i].C(); + } + + for(int i = 0; i < align.mesh->fn; i++) + for(int k = 0; k < 3; k++) + indices[k+i*3] = align.mesh->face[i].V(k) - &*align.mesh->vert.begin(); + + glBindBufferARB(GL_ARRAY_BUFFER_ARB, align.vbo); + glBufferDataARB(GL_ARRAY_BUFFER_ARB, align.mesh->vn*sizeof(vcg::Point3f), + vertices, GL_STATIC_DRAW_ARB); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, align.nbo); + glBufferDataARB(GL_ARRAY_BUFFER_ARB, align.mesh->vn*sizeof(vcg::Point3f), + normals, GL_STATIC_DRAW_ARB); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, align.cbo); + glBufferDataARB(GL_ARRAY_BUFFER_ARB, align.mesh->vn*sizeof(vcg::Color4b), + colors, GL_STATIC_DRAW_ARB); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, align.ibo); + glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, align.mesh->fn*3*sizeof(unsigned int), + indices, GL_STATIC_DRAW_ARB); + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + + + // it is safe to delete after copying data to VBO + delete []vertices; + delete []normals; + delete []colors; for (int h=0; hinitGL(); align.resize(800); - vcg::Point3f *vertices = new vcg::Point3f[align.mesh->vn]; - vcg::Point3f *normals = new vcg::Point3f[align.mesh->vn]; - vcg::Color4b *colors = new vcg::Color4b[align.mesh->vn]; - unsigned int *indices = new unsigned int[align.mesh->fn*3]; - - for(int i = 0; i < align.mesh->vn; i++) { - vertices[i] = align.mesh->vert[i].P(); - normals[i] = align.mesh->vert[i].N(); - colors[i] = align.mesh->vert[i].C(); - } - - for(int i = 0; i < align.mesh->fn; i++) - for(int k = 0; k < 3; k++) - indices[k+i*3] = align.mesh->face[i].V(k) - &*align.mesh->vert.begin(); - - glBindBufferARB(GL_ARRAY_BUFFER_ARB, align.vbo); - glBufferDataARB(GL_ARRAY_BUFFER_ARB, align.mesh->vn*sizeof(vcg::Point3f), - vertices, GL_STATIC_DRAW_ARB); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, align.nbo); - glBufferDataARB(GL_ARRAY_BUFFER_ARB, align.mesh->vn*sizeof(vcg::Point3f), - normals, GL_STATIC_DRAW_ARB); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, align.cbo); - glBufferDataARB(GL_ARRAY_BUFFER_ARB, align.mesh->vn*sizeof(vcg::Color4b), - colors, GL_STATIC_DRAW_ARB); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); - - glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, align.ibo); - glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, align.mesh->fn*3*sizeof(unsigned int), - indices, GL_STATIC_DRAW_ARB); - glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); - - - // it is safe to delete after copying data to VBO - delete []vertices; - delete []normals; - delete []colors; + //align.shot=par.getShotf("Shot");