#ifndef GL_FIELD #define GL_FIELD #include namespace vcg{ template class GLField { typedef typename MeshType::FaceType FaceType; typedef typename MeshType::VertexType VertexType; typedef typename MeshType::CoordType CoordType; typedef typename MeshType::ScalarType ScalarType; static void GLDrawField(CoordType dir[4], CoordType center, ScalarType &size) { glLineWidth(2); vcg::glColor(vcg::Color4b(0,0,255,255)); glBegin(GL_LINES); glVertex(center); glVertex(center+dir[0]*size); glEnd(); glLineWidth(2); vcg::glColor(vcg::Color4b(0,255,0,255)); glBegin(GL_LINES); glVertex(center); glVertex(center+dir[1]*size); glEnd(); /*glLineWidth(1); vcg::glColor(vcg::Color4b(0,0,0,255)); glBegin(GL_LINES); for (int i=1;i<4;i++) { glVertex(center); glVertex(center+dir[i]*size); } glEnd();*/ } ///draw the cross field of a given face static void GLDrawFaceField(const FaceType &f, ScalarType &size) { CoordType center=(f.P0(0)+f.P0(1)+f.P0(2))/3; CoordType normal=f.cN(); CoordType dir[4]; vcg::tri::CrossField::CrossVector(f,dir); GLDrawField(dir,center,size); } static void GLDrawFaceSeams(const FaceType &f, vcg::Point3 seams) { glLineWidth(3); glBegin(GL_LINES); for (int i=0;i<3;i++) { if (!seams[i])continue; glVertex(f.V0(i)->P()); glVertex(f.V1(i)->P()); } glEnd(); } static void GLDrawVertField(const MeshType &mesh, const VertexType &v, ScalarType &size) { CoordType center=v.cP(); CoordType normal=v.cN(); CoordType dir[4]; vcg::tri::CrossField::CrossVector(v,dir); GLDrawField(dir,center,size); } public: ///singular vertices should be selected 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 Handle_Singular; typename MeshType::template PerVertexAttributeHandle Handle_SingularDegree; Handle_Singular=vcg::tri::Allocator::template GetPerVertexAttribute(mesh,std::string("Singular")); Handle_SingularDegree=vcg::tri::Allocator::template GetPerVertexAttribute(mesh,std::string("SingularityDegree")); glPushAttrib(GL_ALL_ATTRIB_BITS); glEnable(GL_COLOR_MATERIAL); glDisable(GL_LIGHTING); glDepthRange(0,0.999); ScalarType size=10; glPointSize(size); glBegin(GL_POINTS); for (unsigned int i=0;i > SeamsHandleType; typedef typename vcg::tri::Allocator SeamsAllocator; SeamsHandleType Handle_Seam; Handle_Seam=SeamsAllocator::template GetPerFaceAttribute >(mesh,std::string("Seams")); 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 (unsigned int i=0;i seams=Handle_Seam[i]; GLDrawFaceSeams(mesh.face[i],seams); } glPopAttrib(); } }; } #endif