From 40c7a794283e215762971716d8377ad34f3a0f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Ulman?= <ulman@mpi-cbg.de> Date: Mon, 10 Oct 2016 17:36:04 +0200 Subject: [PATCH] Finished rendering of the surface... very likely has some error! --- src/graphics.cpp | 54 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/src/graphics.cpp b/src/graphics.cpp index b69de74..7905c15 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -155,20 +155,47 @@ void ActiveMesh::displayQuadricSurface(void) 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 + //do the rendering, i.e., take incident triangles + //and sample points from them and project + //these points on the obtained surface - //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); + //list of neigs triangle IDs + std::vector<size_t> neigsT; + ulm::getVertexIncidentTriangles(*this,VertexID,neigsT); + //FOR CYCLE BEGIN + //over all triangles + for (unsigned int t=0; t < neigsT.size(); ++t) + { + //determine triangle vertices + const Vector3FC& v1=Pos[ID[3*neigsT[t] +0]]; + const Vector3FC& v2=Pos[ID[3*neigsT[t] +1]]; + const Vector3FC& v3=Pos[ID[3*neigsT[t] +2]]; + + //sweep (coarsely!) across current triangle + for (float c=0.1f; c <= 0.9f; c += 0.1f) + for (float b=0.1f; b <= (0.9f-c); b += 0.1f) + { + float a=1.0f -b -c; + + Vector3F point=a*v1; + point+=b*v2; + point+=c*v3; + + //backup... + Vector3F origPoint(point); + + //adapt the point + std::cout << "dist=" << + GetClosestPointOnQuadricSurface(point,surf_coeff); + + //display the point + glVertex3f(point.x,point.y,point.z); + std::cout << "(" << origPoint.x << "," << origPoint.y << "," << origPoint.z + << ") -> (" + << point.x << "," << point.y << "," << point.z << ")\n"; + } + } //FOR CYCLE END glEnd(); @@ -347,12 +374,15 @@ void keyboard(unsigned char key, int mx, int my) case 'M': showWholeMesh^=true; + glutPostRedisplay(); break; case 'V': showVertexSurface^=true; + glutPostRedisplay(); break; case 'Q': showQuadricSurface^=true; + glutPostRedisplay(); break; case 'i': //inspect a cell -- GitLab