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

Added display routine for debugging.

Calculation of the 3rd coordinate seems to work well -- at least for a sphere.
parent ca1333ed
No related branches found
No related tags found
No related merge requests found
...@@ -107,6 +107,7 @@ class ActiveMesh ...@@ -107,6 +107,7 @@ class ActiveMesh
void displayMesh(void); void displayMesh(void);
void displayVertexAndNeigs(void); void displayVertexAndNeigs(void);
void displayQuadricSurface(void); void displayQuadricSurface(void);
void displayTEST(void);
}; };
#endif #endif
...@@ -49,6 +49,7 @@ int last_x = 0, last_y = 0; ...@@ -49,6 +49,7 @@ int last_x = 0, last_y = 0;
bool showWholeMesh=true; bool showWholeMesh=true;
bool showVertexSurface=false; bool showVertexSurface=false;
bool showQuadricSurface=false; bool showQuadricSurface=false;
bool showTEST=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
...@@ -145,6 +146,72 @@ void ActiveMesh::displayVertexAndNeigs(void) ...@@ -145,6 +146,72 @@ void ActiveMesh::displayVertexAndNeigs(void)
glEnd(); glEnd();
} }
void ActiveMesh::displayTEST(void)
{
//get surface params
float surf_coeff[10];
//CalcQuadricSurface_Taubin(VertexID,surf_coeff);
CalcQuadricSurface_sphere(5.0f,params.sceneCentre,surf_coeff);
std::cout << "\nsurface: " << surf_coeff[0] << " + "
<< surf_coeff[1] << "*x + "
<< surf_coeff[2] << "*y + "
<< surf_coeff[3] << "*z + "
<< surf_coeff[4] << "*xy + "
<< surf_coeff[5] << "*xz + "
<< surf_coeff[6] << "*yz + "
<< surf_coeff[7] << "*x*x + "
<< surf_coeff[8] << "*y*y + "
<< surf_coeff[9] << "*z*z = 0\n";
glPointSize(2.0f);
glBegin(GL_POINTS);
glColor3f(0.0f,1.0f,0.0f);
//determine triangle vertices
const Vector3FC& v1=Pos[VertexID];
std::cout << "v1: (" << v1.x << "," << v1.y << "," << v1.z << ")\n";
Vector3F point=v1;
//backup...
Vector3F origPoint(point);
//adapt the point
std::cout << "dist=" <<
GetClosestPointOnQuadricSurface(point,surf_coeff);
//display the point
glColor3f(0.0f,1.0f,0.0f);
//glVertex3f(point.x,point.y,point.z);
float tmp1,tmp2;
if (GetPointOnQuadricSurface(v1.x,v1.y,tmp1,tmp2,surf_coeff))
{
glVertex3f(v1.x,v1.y,tmp1);
glVertex3f(v1.x,v1.y,tmp2);
}
if (GetPointOnQuadricSurface(v1.x,v1.z,tmp1,tmp2,surf_coeff))
{
glVertex3f(v1.x,tmp1,v1.z);
glVertex3f(v1.x,tmp2,v1.z);
}
if (GetPointOnQuadricSurface(v1.y,v1.z,tmp1,tmp2,surf_coeff))
{
glVertex3f(tmp1,v1.y,v1.z);
glVertex3f(tmp2,v1.y,v1.z);
}
/*
std::cout << " (" << origPoint.x << "," << origPoint.y << "," << origPoint.z
<< ") -> ("
<< point.x << "," << point.y << "," << point.z << ")\n";
*/
glColor3f(0.0f,1.0f,1.0f);
//glVertex3f(origPoint.x,origPoint.y,origPoint.z);
glEnd();
}
void ActiveMesh::displayQuadricSurface(void) void ActiveMesh::displayQuadricSurface(void)
{ {
//get surface params //get surface params
...@@ -177,7 +244,7 @@ void ActiveMesh::displayQuadricSurface(void) ...@@ -177,7 +244,7 @@ void ActiveMesh::displayQuadricSurface(void)
//FOR CYCLE BEGIN //FOR CYCLE BEGIN
//over all triangles //over all triangles
//for (unsigned int t=0; t < neigsT.size(); ++t) //for (unsigned int t=0; t < neigsT.size(); ++t)
for (unsigned int t=0; t < 2; ++t) for (unsigned int t=0; t < 1; ++t)
{ {
//determine triangle vertices //determine triangle vertices
const Vector3FC& v1=Pos[ID[3*neigsT[t] +0]]; const Vector3FC& v1=Pos[ID[3*neigsT[t] +0]];
...@@ -259,6 +326,7 @@ void display(void) ...@@ -259,6 +326,7 @@ void display(void)
if (showWholeMesh) mesh.displayMesh(); if (showWholeMesh) mesh.displayMesh();
if (showVertexSurface) mesh.displayVertexAndNeigs(); if (showVertexSurface) mesh.displayVertexAndNeigs();
if (showQuadricSurface) mesh.displayQuadricSurface(); if (showQuadricSurface) mesh.displayQuadricSurface();
if (showTEST) mesh.displayTEST();
glFlush(); glFlush();
glutSwapBuffers(); glutSwapBuffers();
...@@ -403,6 +471,10 @@ void keyboard(unsigned char key, int mx, int my) ...@@ -403,6 +471,10 @@ void keyboard(unsigned char key, int mx, int my)
showQuadricSurface^=true; showQuadricSurface^=true;
glutPostRedisplay(); glutPostRedisplay();
break; break;
case 'T':
showTEST^=true;
glutPostRedisplay();
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);
......
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