Skip to content
Snippets Groups Projects
Commit 9189cf69 authored by Vladimír Ulman's avatar Vladimír Ulman
Browse files

Added various surface visualizations, keys M,V,Q...

parent f7676595
No related branches found
No related tags found
No related merge requests found
...@@ -46,6 +46,10 @@ float zoom = 1.0; ...@@ -46,6 +46,10 @@ float zoom = 1.0;
bool MouseActive = false; bool MouseActive = false;
int last_x = 0, last_y = 0; int last_x = 0, last_y = 0;
bool showWholeMesh=true;
bool showVertexSurface=false;
bool showQuadricSurface=false;
///manage \e count steps of the simulation and then print and draw ///manage \e count steps of the simulation and then print and draw
void step(int count) void step(int count)
...@@ -107,24 +111,73 @@ void displayAxes(void) ...@@ -107,24 +111,73 @@ void displayAxes(void)
int VertexID=10; int VertexID=10;
void ActiveMesh::displayMesh(void) int vertexLevels=5;
void ActiveMesh::displayVertexAndNeigs(void)
{ {
glColor3f(0.8f,0.8f,0.8f); //determine some reasonable number of nearest neighbors
std::vector< std::vector<size_t> > neigsLeveled;
ulm::getVertexNeighbours(*this,VertexID,vertexLevels,neigsLeveled);
//make it flat...
std::vector<size_t> neigs;
for (unsigned int l=0; l < neigsLeveled.size(); ++l)
for (unsigned int i=0; i < neigsLeveled[l].size(); ++i)
neigs.push_back(neigsLeveled[l][i]);
neigsLeveled.clear();
/* /*
for (unsigned int i=0; i < ID.size(); i+=3) std::vector<size_t> neigs;
{ ulm::getVertexImmediateNeighbours(*this,VertexID,neigs);
//glBegin(GL_TRIANGLES);
glBegin(GL_LINE_LOOP);
glNormal3f(norm[i/3].x,norm[i/3].y,norm[i/3].z);
glVertex3f(Pos[ID[i+0]].x,Pos[ID[i+0]].y,Pos[ID[i+0]].z);
glVertex3f(Pos[ID[i+1]].x,Pos[ID[i+1]].y,Pos[ID[i+1]].z);
glVertex3f(Pos[ID[i+2]].x,Pos[ID[i+2]].y,Pos[ID[i+2]].z);
glEnd();
}
*/ */
//long unsigned int* id=&ID.front(); glPointSize(3.0f);
glBegin(GL_POINTS);
// centre vertex:
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(Pos[VertexID].x,Pos[VertexID].y,Pos[VertexID].z);
// neigs:
glColor3f(1.0f,0.0f,0.0f);
for (unsigned int i=1; i < neigs.size(); ++i)
glVertex3f(Pos[neigs[i]].x,Pos[neigs[i]].y,Pos[neigs[i]].z);
glEnd();
}
void ActiveMesh::displayQuadricSurface(void)
{
//get surface params
float surf_coeff[10];
CalcQuadricSurface_Taubin(VertexID,surf_coeff);
glPointSize(2.0f);
glBegin(GL_POINTS);
glColor3f(0.0f,1.0f,0.0f);
//do the rendering
//hmm... figure out some iteration model..
//perhaps from surrounding points some interpolation
//FOR CYCLE BEGIN
Vector3F point;
//say we have x,y,z -> point
//adapt the point
GetClosestPointOnQuadricSurface(point,surf_coeff);
//display the point
glVertex3f(point.x,point.y,point.z);
//FOR CYCLE END
glEnd();
}
void ActiveMesh::displayMesh(void)
{
glColor3f(0.8f,0.8f,0.8f);
long unsigned int* id=ID.data(); long unsigned int* id=ID.data();
for (unsigned int i=0; i < ID.size(); i+=3) for (unsigned int i=0; i < ID.size(); i+=3)
{ {
...@@ -136,20 +189,6 @@ void ActiveMesh::displayMesh(void) ...@@ -136,20 +189,6 @@ void ActiveMesh::displayMesh(void)
glVertex3f(Pos[*id].x,Pos[*id].y,Pos[*id].z); ++id; glVertex3f(Pos[*id].x,Pos[*id].y,Pos[*id].z); ++id;
glEnd(); glEnd();
} }
std::vector<size_t> neigs;
ulm::getVertexImmediateNeighbours(*this,VertexID,neigs);
glPointSize(4.0f);
glBegin(GL_POINTS);
// centre vertex:
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(Pos[VertexID].x,Pos[VertexID].y,Pos[VertexID].z);
// neigs:
glColor3f(1.0f,0.0f,0.0f);
for (unsigned int i=0; i < neigs.size(); ++i)
glVertex3f(Pos[neigs[i]].x,Pos[neigs[i]].y,Pos[neigs[i]].z);
glEnd();
} }
...@@ -170,7 +209,10 @@ void display(void) ...@@ -170,7 +209,10 @@ void display(void)
displayFrame(); displayFrame();
displayAxes(); displayAxes();
mesh.displayMesh();
if (showWholeMesh) mesh.displayMesh();
if (showVertexSurface) mesh.displayVertexAndNeigs();
if (showQuadricSurface) mesh.displayQuadricSurface();
glFlush(); glFlush();
glutSwapBuffers(); glutSwapBuffers();
...@@ -303,6 +345,16 @@ void keyboard(unsigned char key, int mx, int my) ...@@ -303,6 +345,16 @@ void keyboard(unsigned char key, int mx, int my)
glutPostRedisplay(); glutPostRedisplay();
break; break;
case 'M':
showWholeMesh^=true;
break;
case 'V':
showVertexSurface^=true;
break;
case 'Q':
showQuadricSurface^=true;
break;
case 'i': //inspect a cell case 'i': //inspect a cell
GetSceneViewSize(windowSizeX,windowSizeY, xVisF,xVisT,yVisF,yVisT); GetSceneViewSize(windowSizeX,windowSizeY, xVisF,xVisT,yVisF,yVisT);
sx=(float)mx /(float)windowSizeX * (xVisT-xVisF) + xVisF; sx=(float)mx /(float)windowSizeX * (xVisT-xVisF) + xVisF;
......
...@@ -34,8 +34,10 @@ int main(void) ...@@ -34,8 +34,10 @@ int main(void)
mesh.CenterMesh(params.sceneCentre); mesh.CenterMesh(params.sceneCentre);
//work with mesh //work with mesh
/*
float surf_coeff[10]; float surf_coeff[10];
mesh.CalcQuadricSurface_Taubin(10,surf_coeff); mesh.CalcQuadricSurface_Taubin(10,surf_coeff);
*/
/* /*
//render mesh //render mesh
...@@ -50,11 +52,9 @@ int main(void) ...@@ -50,11 +52,9 @@ int main(void)
mask.SaveImage("mesh.ics"); mask.SaveImage("mesh.ics");
*/ */
/*
initializeGL(); initializeGL();
loopGL(); loopGL();
closeGL(); closeGL();
*/
return(0); return(0);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment