Edge-Dependent Attributes

Suppose we want to obtain a polygonal object by linearization of the parametric shell and store in the vertices 2D parameters on the corresponding faces. Each face has a corresponding region in the segmentation. However, the numeration of vertices in a polygon object is continuous and uniform for the whole mesh. For the mesh vertices lying on the edges and in the segmentation vertices, we get an ambiguous situation. If a vertex belongs to one face, this vertex has a 2D parameter connected with this face, but at the same time this vertex also belongs to a different face with a different 2D parameter connected with that face. Thus, it is impossible to describe 2D parameters by a simple attribute that assigns only one parameter to each vertex. The same issue occurs with values such as normals and curvatures.

To solve this issue, the module provides edge-dependent attributes. They are inherited from the MbHalfedgeAttrEdgeDependentVertexBase base class. There are three such attributes:

  • MbHalfedgeAttrParamByEdge;

  • MbHalfedgeAttrNormalsVertex;

  • MbHalfedgeAttrCurvaturesVertex.

Let’s consider their structure based on the normals example. All normals are stored in a separate array, and their indices and number have no direct connection with the mesh vertices. Each edge of the mesh is assigned an index in the normals array. For an internal vertex, all edges of its fan point to the same normal. If the vertex belongs to a segmentation edge or a segmentation vertex, then different edges of the fan point to different normals.

This is the detailed example with a simple mesh with four triangle facets in Fig. 1. The normal in the vertex is calculated by averaging the normals of the facets included in the vertex fan. There are two cases:

  • the first case when the whole mesh forms one smooth object (see Fig. a)),

  • the second case when the mesh is segmented into two flat regions (see Fig. c)).

The direction of the normals is shown by the red lines. The vertex fan has three edges starting from this vertex. On the right image they all refer to the same normal. On the left image two red edges (see Fig. b)) refer to normal N1, and one green edge refers to normal N2.

../../../_images/P.2.5.1.png

Fig. 1

So, if the normals exist, the visualization of segmented and unsegmented meshes is significantly different, as shown in Fig. 2:

../../../_images/P.2.5.2.png

Fig. 2

Attention! Do not use the method

const MbVector3D & GetNormal( size_t iNm ) const;

with vertex indices as an input parameter or interpret it as a way to have one normal per vertex.

You must use the method

const MbVector3D & GetNormalEdge( size_t iEd ) const;

instead, receiving normals for each edge from the vertex fan separately.

There is no way for a user to explicitly create edge-dependent attribute types. They can be created only through functions providing these values calculation. These functions set the attribute structure corresponding to the current segmentation. In case of any changes in the segmentation topology (merging regions, splitting by mesh edges or facets and so on), the structure of the existing edge-dependent attributes is also changed according to the new segmentation.