added GLDrawSeams function

This commit is contained in:
Nico Pietroni 2012-09-03 15:58:38 +00:00
parent be2d3613b9
commit a4ee21d5d7
1 changed files with 53 additions and 15 deletions

View File

@ -4,25 +4,34 @@ class GLField
{ {
typedef typename MeshType::FaceType FaceType; typedef typename MeshType::FaceType FaceType;
typedef typename MeshType::VertexType VertexType; typedef typename MeshType::VertexType VertexType;
typedef typename MeshType::CoordType CoordType;
typedef typename MeshType::ScalarType ScalarType; typedef typename MeshType::ScalarType ScalarType;
static void GLDrawField(CoordType dir[4], static void GLDrawField(CoordType dir[4],
CoordType center, CoordType center,
ScalarType &size) ScalarType &size)
{ {
glLineWidth(1);
vcg::Color4b c; glLineWidth(3);
vcg::glColor(vcg::Color4b(0,0,0,255)); vcg::glColor(vcg::Color4b(0,0,255,255));
glBegin(GL_LINES);
glVertex(center);
glVertex(center+dir[0]*size);
glEnd();
glLineWidth(1);
vcg::glColor(vcg::Color4b(0,0,0,255));
glBegin(GL_LINES); glBegin(GL_LINES);
for (int i=0;i<4;i++) for (int i=1;i<4;i++)
{ {
glVertex(center); glVertex(center);
glVertex(center+dir[i]*size); glVertex(center+dir[i]*size);
} }
glEnd(); glEnd();
} }
///draw the cross field of a given face ///draw the cross field of a given face
static void GLDrawFaceField(const MeshType &mesh, static void GLDrawFaceField(const MeshType &mesh,
const FaceType &f, const FaceType &f,
@ -35,6 +44,21 @@ class GLField
GLDrawField(dir,center,size); GLDrawField(dir,center,size);
} }
static void GLDrawFaceSeams(const FaceType &f)
{
glLineWidth(3);
glBegin(GL_LINES);
for (int i=0;i<3;i++)
{
if (!f.IsSeam(i))continue;
glVertex(f.V0(i)->P());
glVertex(f.V1(i)->P());
}
glEnd();
}
static void GLDrawVertField(const MeshType &mesh, static void GLDrawVertField(const MeshType &mesh,
const VertexType &v, const VertexType &v,
ScalarType &size) ScalarType &size)
@ -55,7 +79,7 @@ public:
glEnable(GL_COLOR_MATERIAL); glEnable(GL_COLOR_MATERIAL);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glDepthRange(0,0.999); glDepthRange(0,0.999);
MyScalarType size=10; ScalarType size=10;
glPointSize(size); glPointSize(size);
glBegin(GL_POINTS); glBegin(GL_POINTS);
for (int i=0;i<mesh.vert.size();i++) for (int i=0;i<mesh.vert.size();i++)
@ -86,9 +110,8 @@ public:
glPushAttrib(GL_ALL_ATTRIB_BITS); glPushAttrib(GL_ALL_ATTRIB_BITS);
glEnable(GL_COLOR_MATERIAL); glEnable(GL_COLOR_MATERIAL);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
MyScalarType size=mesh.bbox.Diag()/100.0; ScalarType size=mesh.bbox.Diag()/400.0;
vcg::Color4b c=vcg::Color4b(255,0,0,255); for (int i=0;i<mesh.face.size();i++)
for (int i=0;i<mesh.face.size();i++)
{ {
if (mesh.face[i].IsD())continue; if (mesh.face[i].IsD())continue;
//if (!mesh.face[i].leading)continue; //if (!mesh.face[i].leading)continue;
@ -102,9 +125,8 @@ public:
glPushAttrib(GL_ALL_ATTRIB_BITS); glPushAttrib(GL_ALL_ATTRIB_BITS);
glEnable(GL_COLOR_MATERIAL); glEnable(GL_COLOR_MATERIAL);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
MyScalarType size=mesh.bbox.Diag()/100.0; ScalarType size=mesh.bbox.Diag()/100.0;
vcg::Color4b c=vcg::Color4b(255,0,0,255); for (int i=0;i<mesh.vert.size();i++)
for (int i=0;i<mesh.vert.size();i++)
{ {
if (mesh.vert[i].IsD())continue; if (mesh.vert[i].IsD())continue;
//if (!mesh.face[i].leading)continue; //if (!mesh.face[i].leading)continue;
@ -112,5 +134,21 @@ public:
} }
glPopAttrib(); glPopAttrib();
} }
static void GLDrawSeams(const MeshType &mesh)
{
glPushAttrib(GL_ALL_ATTRIB_BITS);
glEnable(GL_COLOR_MATERIAL);
glDisable(GL_LIGHTING);
vcg::glColor(vcg::Color4b(255,0,0,255));
glDepthRange(0,0.999);
for (int i=0;i<mesh.face.size();i++)
{
if (mesh.face[i].IsD())continue;
GLDrawFaceSeams(mesh.face[i]);
}
glPopAttrib();
}
}; };
} }