diff --git a/cmath3d/TriangleMesh.h b/cmath3d/TriangleMesh.h index 4b3c5a9fb0423cdf78a13a5895a595bac8351b2d..7aa390972040f3077171215ec08f17a3d0805fea 100644 --- a/cmath3d/TriangleMesh.h +++ b/cmath3d/TriangleMesh.h @@ -107,6 +107,7 @@ class ActiveMesh void displayMesh(void); void displayVertexAndNeigs(void); void displayQuadricSurface(void); + void displayTEST(void); }; #endif diff --git a/src/graphics.cpp b/src/graphics.cpp index 34cd5959d5faba76753193fd3f56f1201b755e79..aa1945f6605dc86ad8ca471de582247e2befbaac 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -49,6 +49,7 @@ int last_x = 0, last_y = 0; bool showWholeMesh=true; bool showVertexSurface=false; bool showQuadricSurface=false; +bool showTEST=false; ///manage \e count steps of the simulation and then print and draw @@ -145,6 +146,72 @@ void ActiveMesh::displayVertexAndNeigs(void) 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) { //get surface params @@ -177,7 +244,7 @@ void ActiveMesh::displayQuadricSurface(void) //FOR CYCLE BEGIN //over all triangles //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 const Vector3FC& v1=Pos[ID[3*neigsT[t] +0]]; @@ -259,6 +326,7 @@ void display(void) if (showWholeMesh) mesh.displayMesh(); if (showVertexSurface) mesh.displayVertexAndNeigs(); if (showQuadricSurface) mesh.displayQuadricSurface(); + if (showTEST) mesh.displayTEST(); glFlush(); glutSwapBuffers(); @@ -403,6 +471,10 @@ void keyboard(unsigned char key, int mx, int my) showQuadricSurface^=true; glutPostRedisplay(); break; + case 'T': + showTEST^=true; + glutPostRedisplay(); + break; case 'i': //inspect a cell GetSceneViewSize(windowSizeX,windowSizeY, xVisF,xVisT,yVisF,yVisT);