MNMesh Edges

MNMesh like the regular Mesh class has no edge data members. Edge selection and visibility data must initially be stored in the MNFace members. Before a call to MNMesh::FillInMesh() there are no MNEdges to store them in. There are a number of methods in the library (and many more the developer could design) which would invalidate the topological data, rendering the MNEdge list invalid. Also, eventually, we're going to want to convert each MNMesh back into a regular mesh using the MNMesh::OutToTri() method, so it's convenient to store edge selection and visibility information in the faces for this purpose.

Thus, although the MNEdgescontain MN_SEL and MN_EDGE_INVIS flags, the more fundamental location for this data is in the MNFaces using that edge. When altering an MNMesh to make edges visible or invisible, or to change their selection status, be sure to make the changes in the MNFaces using the edge, otherwise the information can be easily overwritten, and generally won't get passed to the output mesh.

The methods MNMesh::SetEdgeVis() and MNMesh::SetEdgeSel() are the best way to do this, as they also set the visedg state of the faces on either side. You can also set the face's visedg state directly (as shown below).

The following demonstrates how to make an edge visible and selected:

void MakeEdgeVisAndSel(MNMesh & mm, int ee)
{
   assert(mm.GetFlag(MN_MESH_FILLED_IN));
   MNEdge *me = mm.E(ee);
   MNFace *mf1 = mm.F(me->f1);
   MNFace *mf2 =(me->f2>-1) ? mm.F(me->f2) : NULL;

   // Change the edge as desired
   me->ClearFlag(MN_EDGE_INVIS | MN_EDGE_HALF_INVIS);
   me->SetFlag(MN_SEL);

   // Make the corresponding changes in face 1
   inti;
   i = mf1->EdgeIndex(ee);
   mf1->visedg.Set(i);
   mf1->edgsel.Set(i);

   // Make the corresponding changes in face 2
   if(mf2)
   {
     i = mf2->EdgeIndex(ee);
     mf2->visedg.Set(i);
     mf2->edgsel.Set(i);
   }
}