major modifications
This commit is contained in:
parent
5445d99402
commit
c469b5b948
|
@ -6,15 +6,10 @@ class GLField
|
||||||
typedef typename MeshType::VertexType VertexType;
|
typedef typename MeshType::VertexType VertexType;
|
||||||
typedef typename MeshType::ScalarType ScalarType;
|
typedef typename MeshType::ScalarType ScalarType;
|
||||||
|
|
||||||
///draw the cross field of a given face
|
static void GLDrawField(CoordType dir[4],
|
||||||
static void GLDrawField(MeshType &mesh,
|
CoordType center,
|
||||||
const FaceType &f,
|
|
||||||
ScalarType &size)
|
ScalarType &size)
|
||||||
{
|
{
|
||||||
CoordType center=(f.P0(0)+f.P0(1)+f.P0(2))/3;
|
|
||||||
CoordType normal=f.cN();
|
|
||||||
CoordType dir[4];
|
|
||||||
vcg::tri::CrossField<MeshType>::CrossVector(f,dir);
|
|
||||||
glLineWidth(1);
|
glLineWidth(1);
|
||||||
vcg::Color4b c;
|
vcg::Color4b c;
|
||||||
vcg::glColor(vcg::Color4b(0,0,0,255));
|
vcg::glColor(vcg::Color4b(0,0,0,255));
|
||||||
|
@ -28,6 +23,28 @@ class GLField
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///draw the cross field of a given face
|
||||||
|
static void GLDrawFaceField(const MeshType &mesh,
|
||||||
|
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<MeshType>::CrossVector(f,dir);
|
||||||
|
GLDrawField(dir,center,size);
|
||||||
|
}
|
||||||
|
|
||||||
|
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<MeshType>::CrossVector(v,dir);
|
||||||
|
GLDrawField(dir,center,size);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -41,12 +58,12 @@ public:
|
||||||
MyScalarType size=10;
|
MyScalarType size=10;
|
||||||
glPointSize(size);
|
glPointSize(size);
|
||||||
glBegin(GL_POINTS);
|
glBegin(GL_POINTS);
|
||||||
for (int i=0;i<mymesh.vert.size();i++)
|
for (int i=0;i<mesh.vert.size();i++)
|
||||||
{
|
{
|
||||||
if (mymesh.vert[i].IsD())continue;
|
if (mesh.vert[i].IsD())continue;
|
||||||
if (!mymesh.vert[i].IsS())continue;
|
if (!mesh.vert[i].IsS())continue;
|
||||||
int mmatch;
|
int mmatch;
|
||||||
bool IsSing=vcg::tri::CrossField<MeshType>::IsSingular(mymesh.vert[i],mmatch);
|
bool IsSing=vcg::tri::CrossField<MeshType>::IsSingular(mesh.vert[i],mmatch);
|
||||||
if (!IsSing)continue;
|
if (!IsSing)continue;
|
||||||
assert(IsSing);
|
assert(IsSing);
|
||||||
assert(mmatch!=0);
|
assert(mmatch!=0);
|
||||||
|
@ -57,24 +74,41 @@ public:
|
||||||
else
|
else
|
||||||
if (mmatch==3)vcg::glColor(vcg::Color4b(0,255,255,255));
|
if (mmatch==3)vcg::glColor(vcg::Color4b(0,255,255,255));
|
||||||
|
|
||||||
vcg::glVertex(mymesh.vert[i].P());
|
vcg::glVertex(mesh.vert[i].P());
|
||||||
|
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GLDrawFaceField(const MeshType &mesh)
|
static void GLDrawFaceField(const MeshType &mesh)
|
||||||
{
|
{
|
||||||
srand(12345);
|
|
||||||
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=mymesh.bbox.Diag()/100.0;
|
MyScalarType size=mesh.bbox.Diag()/100.0;
|
||||||
vcg::Color4b c=vcg::Color4b(255,0,0,255);
|
vcg::Color4b c=vcg::Color4b(255,0,0,255);
|
||||||
for (int i=0;i<mymesh.face.size();i++)
|
for (int i=0;i<mesh.face.size();i++)
|
||||||
{
|
{
|
||||||
if (mymesh.face[i].IsD())continue;
|
if (mesh.face[i].IsD())continue;
|
||||||
GLDrawField(mymesh,mymesh.face[i],size);
|
//if (!mesh.face[i].leading)continue;
|
||||||
|
GLDrawFaceField(mesh,mesh.face[i],size);
|
||||||
|
}
|
||||||
|
glPopAttrib();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void GLDrawVertField(const MeshType &mesh)
|
||||||
|
{
|
||||||
|
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||||
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
|
glDisable(GL_LIGHTING);
|
||||||
|
MyScalarType size=mesh.bbox.Diag()/100.0;
|
||||||
|
vcg::Color4b c=vcg::Color4b(255,0,0,255);
|
||||||
|
for (int i=0;i<mesh.vert.size();i++)
|
||||||
|
{
|
||||||
|
if (mesh.vert[i].IsD())continue;
|
||||||
|
//if (!mesh.face[i].leading)continue;
|
||||||
|
GLDrawVertField(mesh,mesh.vert[i],size);
|
||||||
}
|
}
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue