Default MESH entity data

Introduction

The MESH scene graph contains template nodes and entities, to provide a fully customizable flexible data structure. The base entities are the vertices, edges and faces. These classes contain the topological informations in their non-template part. Other informations are stored in their template part.

In this page we describe the default template datas. In other words, we describe the attributes of the X3DTK::MESH::SFVertex, X3DTK::MESH::SFEdge, X3DTK::MESH::SFFace and X3DTK::MESH::Mesh classes.

For more informations about these classes, refer to the MESH scene graph API page The default mesh datas correspond to the datas of an X3DTK::X3D::IndexedFaceSet so that there is no loss of information between a standard X3D scene graph and a MESH scene graph.

For each class, two syntaxes are proposed. The first one is about the default classes, and the second one is for generic code.

X3DTK::MESH::VertexData class

The X3DTK::MESH::VertexData class is the aggregation of the X3DTK::MESH::VertexPointData, X3DTK::MESH::VertexNormalData, X3DTK::MESH::VertexColorData and X3DTK::MESH::VertexTexCoordData.

// Defining the default vertex X3DTK::MESH::SFVertex *v; // Defining the generic vertex X3DTK::MESH::SFTemplateVertex<MData, VData, EData, FData> *gv;

X3DTK::MESH::VertexPointData class

This class stores the coordinates of a vertex:
// Getting the point const SFPoint3f &p = v->data().getPoint(); const SFPoint3f &gp = gv->template ogetData<X3DTK::MESH::VertexPointData>().getPoint(); // Setting the point v->data().setPoint(p); gv->template ogetData<X3DTK::MESH::VertexPointData>().setPoint(gp);

X3DTK::MESH::VertexNormalData class

This class stores the normals of a vertex. One normal is defined per face around the vertex. The mesh is continue in a vertex V for the normals if V has the same normals for the faces around.

// Defining a face X3DTK::MESH::SFFace *f; X3DTK::MESH::SFTemplateFace<MData, VData, EData, FData> *gf; // Getting the normal of face const SFVec3f &n = v->data().getNormalOfFace(f); const SFVec3f &gn = gv->template ogetData<X3DTK::MESH::VertexNormalData>().getNormalOfFace(gf); // Setting the normal of face v->data().setNormalOfFace(f, n); gv->template ogetData<X3DTK::MESH::VertexNormalData>().setNormalOfFace(gf, gn);

X3DTK::MESH::VertexColorData class

This class stores the colors of a vertex. One color is defined per face around the vertex. The mesh is continue in a vertex V for the colors if V has the same colors for the faces around.

// Defining a face X3DTK::MESH::SFFace *f; X3DTK::MESH::SFTemplateFace<MData, VData, EData, FData> *gf; // Getting the color of face const SFColorRGBA &c = v->data().getColorOfFace(f); const SFColorRGBA &gc = gv->template ogetData<X3DTK::MESH::VertexColorData>().getColorOfFace(gf); // Setting the color of face v->data().setColorOfFace(f, c); gv->template ogetData<X3DTK::MESH::VertexColorData>().setColorOfFace(gf, gc);

X3DTK::MESH::VertexTexCoordData class

This class stores the texture coordinates of a vertex:
// Getting the texture coordinate const SFPoint2f &p = v->data().getTexCoord(); const SFPoint2f &gp = gv->template ogetData<X3DTK::MESH::VertexTexCoordData>().getTexCoord(); // Setting the texture coordinate v->data().setTexCoord(p); gv->template ogetData<X3DTK::MESH::VertexTexCoordData>().setTexCoord(gp);

X3DTK::MESH::EdgeData class

The X3DTK::MESH::EdgeData class is empty.

X3DTK::MESH::FaceData class

The X3DTK::MESH::FaceData class is the aggregation of the X3DTK::MESH::FaceNormalData and X3DTK::MESH::FaceColorData.

// Defining the default face X3DTK::MESH::SFFace *f; // Defining the generic face X3DTK::MESH::SFTemplateFace<MData, VData, EData, FData> *gf;

X3DTK::MESH::FaceNormalData class

This class stores the normal of a face:

// Getting the normal const SFVec3f &n = f->data().getNormal(); const SFVec3f &gn = gf->template ogetData<X3DTK::MESH::FaceNormalData>().getNormal(); // Setting the normal v->data().setNormal(n); gv->template ogetData<X3DTK::MESH::FaceNormalData>().setNormal(gn);

X3DTK::MESH::FaceNormalData class

This class stores the color of a face:

// Getting the color const SFColorRGBA &c = f->data().getColor(); const SFColorRGBA &gn = gf->template ogetData<X3DTK::MESH::FaceColorData>().getColor(); // Setting the color v->data().setColor(c); gv->template ogetData<X3DTK::MESH::FaceColorData>().setColor(gc);

X3DTK::MESH::MeshData class

The X3DTK::MESH::MeshData class is the aggregation of the X3DTK::MESH::MeshNormalData, X3DTK::MESH::MeshColorData, X3DTK::MESH::MeshTexCoordData and X3DTK::MESH::MeshSolidData.

// Defining the default mesh X3DTK::MESH::Mesh *M; // Defining the generic mesh X3DTK::MESH::TemplateMesh<MData, VData, EData, FData> *GM; *

X3DTK::MESH::MeshNormalData class

This class sets the mesh informations relative to the normals.

// Testing whether the mesh has normals or not bool n = M->data().hasNormal(); bool gn = M->data().template ogetData<X3DTK::MESH::MeshNormalData>.hasNormal(); // Testing whether the mesh has normals per vertex or not bool nv = M->data().getNormalPerVertex(); bool gnv = M->template ogetData<X3DTK::MESH::MeshNormalData>.getNormalPerVertex(); // Getting the crease angle float c = M->data().getCreaseAngle(); float gc = M->template ogetData<X3DTK::MESH::MeshNormalData>.getCreaseAngle(); // Setting the normal presence M->data().setNormal(n); M->data().template ogetData<X3DTK::MESH::MeshNormalData>.setNormal(gn); // Setting the normal per vertex M->data().setNormalPerVertex(nv); M->template ogetData<X3DTK::MESH::MeshNormalData>.setNormalPerVertex(gnv); // Setting the crease angle M->data().getCreaseAngle(c); M->template ogetData<X3DTK::MESH::MeshNormalData>.setCreaseAngle(gc);

X3DTK::MESH::MeshColorData class

This class sets the mesh informations relative to the colors.

// Testing whether the mesh has colors or not bool c = M->data().hasColor(); bool gc = M->data().template ogetData<X3DTK::MESH::MeshColorData>.hasColor(); // Testing whether the mesh has colors per vertex or not bool cv = M->data().getColorPerVertex(); bool gcv = M->template ogetData<X3DTK::MESH::MeshColorData>.getColorPerVertex(); // Testing whether colors are RGBA or not. bool a = M->data().getRGBA(); bool ga = M->template ogetData<X3DTK::MESH::MeshColorData>.getRGBA(); // Setting the color presence M->data().setColor(c); M->data().template ogetData<X3DTK::MESH::MeshColorData>.setColor(gc); // Testing whether the mesh has colors per vertex or not M->data().setColorPerVertex(cv); M->template ogetData<X3DTK::MESH::MeshColorData>.setColorPerVertex(gcv); // Testing whether colors are RGBA or not. M->data().setRGBA(a); M->template ogetData<X3DTK::MESH::MeshColorData>.setRGBA(ga);

X3DTK::MESH::MeshTexCoordData class

This class sets the mesh informations relative to the texture coordinates.

// Testing whether the mesh has texture coordinates or not bool t = M->data().hasTexCoord(); bool gt = M->data().template ogetData<X3DTK::MESH::MeshTexCoordData>.hasTexCoord(); // Setting the texture coordinates presence M->data().setTexCoord(t); M->data().template ogetData<X3DTK::MESH::MeshTexCoordData>.setTexCoord(gt);

X3DTK::MESH::MeshSolidData class

// Testing whether the mesh has solid faces bool s = M->data().isSolid(); bool gs = M->data().template ogetData<X3DTK::MESH::MeshSolidData>.isSolid(); // Setting the solid faces M->data().setSolid(s); M->data().template ogetData<X3DTK::MESH::MeshSolidData>.setSolid(s);

Creating a new data class

You can create a new data class for customizing the vertices, edges, faces or meshes. Notice that in a data class, because of implementation constraints, you cannot access directly the datas of another entity. You can just access its pointer. That is why you access an X3DTK::MESH::BaseSFVertex, X3DTK::MESH::BaseSFEdge or X3DTK::MESH::BaseSFFace.

Suppose that you define an X3DTK::MESH::VertexDistanceData for the vertex entity. To aggregate the different data class you need for a vertex, you just have to use type lists like this:

// Defining a new information per vertex per face: class VertexDistanceData { public: VertexDistanceData(); void setDistanceOfFace(BaseSFFace *f, float distance); float getDistanceOfFace(BaseSFFace *f) const; }; typedef clist<tlist<VertexPointData, tlist<VertexColorData, tlist<VertexDistanceData> > > > MyVertexData; // Using the template type X3DTK::MESH::SFTemplateVertex<MyVertexData, EdgeData, FaceData, true> *v; //accessing directly the information float distance = v->data().getDistanceOfFace(f);

Then you have to write a processor that fills the distance values. For an example on how to define your own data, see meshExtension.

Examples

Here is the list of the examples where the default MESH datas are used:
Generated on Fri Jul 30 12:02:31 2004 for X3DToolKit by doxygen 1.3.6