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 MNMesh::FillInMesh() to 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 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 MNFacesusing that edge. When altering an MNMesh to make edges visible or invisible, or to change their selectionstatus, be sure to make the changes in the MNFacesusing the edge, otherwise the information can be easilyoverwritten, and generally won't get passed to the output mesh.

The methods MNMesh::SetEdgeVis() and MNMesh::SetEdgeSel() do this.

The following demonstrates how to make and 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);
   }
}