used per vertex and per face optional attributes

This commit is contained in:
Nico Pietroni 2012-10-15 01:13:30 +00:00
parent 8d4bdc467e
commit 52648c58ad
1 changed files with 40 additions and 19 deletions

View File

@ -54,14 +54,15 @@ class GLField
GLDrawField(dir,center,size); GLDrawField(dir,center,size);
} }
static void GLDrawFaceSeams(const FaceType &f) static void GLDrawFaceSeams(const FaceType &f,
vcg::Point3<bool> seams)
{ {
glLineWidth(3); glLineWidth(3);
glBegin(GL_LINES); glBegin(GL_LINES);
for (int i=0;i<3;i++) for (int i=0;i<3;i++)
{ {
if (!f.IsSeam(i))continue; if (!seams[i])continue;
glVertex(f.V0(i)->P()); glVertex(f.V0(i)->P());
glVertex(f.V1(i)->P()); glVertex(f.V1(i)->P());
@ -83,8 +84,20 @@ class GLField
public: public:
///singular vertices should be selected ///singular vertices should be selected
static void GLDrawSingularities(const MeshType &mesh) static void GLDrawSingularities(MeshType &mesh)
{ {
bool hasSingular = vcg::tri::HasPerVertexAttribute(mesh,std::string("Singular"));
bool hasSingularDegree = vcg::tri::HasPerVertexAttribute(mesh,std::string("SingularityDegree"));
if (!hasSingular)return;
typename MeshType::template PerVertexAttributeHandle<bool> Handle_Singular;
typename MeshType::template PerVertexAttributeHandle<int> Handle_SingularDegree;
Handle_Singular=vcg::tri::Allocator<MeshType>::template GetPerVertexAttribute<bool>(mesh,std::string("Singular"));
Handle_SingularDegree=vcg::tri::Allocator<MeshType>::template GetPerVertexAttribute<int>(mesh,std::string("SingularityDegree"));
glPushAttrib(GL_ALL_ATTRIB_BITS); glPushAttrib(GL_ALL_ATTRIB_BITS);
glEnable(GL_COLOR_MATERIAL); glEnable(GL_COLOR_MATERIAL);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
@ -95,13 +108,12 @@ public:
for (unsigned int i=0;i<mesh.vert.size();i++) for (unsigned int i=0;i<mesh.vert.size();i++)
{ {
if (mesh.vert[i].IsD())continue; if (mesh.vert[i].IsD())continue;
if (!mesh.vert[i].IsSingular())continue; if (!Handle_Singular[i])continue;
int mmatch=mesh.vert[i].missmatch; int mmatch=3;
//bool IsSing=vcg::tri::CrossField<MeshType>::IsSingular(mesh.vert[i],mmatch); if (hasSingularDegree)
//if (!IsSing)continue; mmatch=Handle_SingularDegree[i];
//assert(IsSing);
assert(mmatch!=0);
/*vcg::glColor(vcg::Color4b(255,0,0,255));*/
if (mmatch==1)vcg::glColor(vcg::Color4b(0,0,255,255)); if (mmatch==1)vcg::glColor(vcg::Color4b(0,0,255,255));
else else
if (mmatch==2)vcg::glColor(vcg::Color4b(255,0,0,255)); if (mmatch==2)vcg::glColor(vcg::Color4b(255,0,0,255));
@ -145,8 +157,16 @@ public:
glPopAttrib(); glPopAttrib();
} }
static void GLDrawSeams(const MeshType &mesh) static void GLDrawSeams(MeshType &mesh)
{ {
bool hasSeam = vcg::tri::HasPerFaceAttribute(mesh,std::string("Seams"));
if(!hasSeam)return;
typedef typename MeshType::template PerFaceAttributeHandle<vcg::Point3<bool> > SeamsHandleType;
typedef typename vcg::tri::Allocator<MeshType> SeamsAllocator;
SeamsHandleType Handle_Seam;
Handle_Seam=SeamsAllocator::template GetPerFaceAttribute<vcg::Point3<bool> >(mesh,std::string("Seams"));
glPushAttrib(GL_ALL_ATTRIB_BITS); glPushAttrib(GL_ALL_ATTRIB_BITS);
glEnable(GL_COLOR_MATERIAL); glEnable(GL_COLOR_MATERIAL);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
@ -155,7 +175,8 @@ public:
for (unsigned int i=0;i<mesh.face.size();i++) for (unsigned int i=0;i<mesh.face.size();i++)
{ {
if (mesh.face[i].IsD())continue; if (mesh.face[i].IsD())continue;
GLDrawFaceSeams(mesh.face[i]); vcg::Point3<bool> seams=Handle_Seam[i];
GLDrawFaceSeams(mesh.face[i],seams);
} }
glPopAttrib(); glPopAttrib();
} }