title: Openmesh: How to modify mesh faces? (And how to random access component handles?)
body: <p>I just started using OpenMesh in Python. I started off by trying to make a PolyMesh consisting of a single quad. This is what I did:</p>
  
  <pre><code>from openmesh import *
  mesh = PolyMesh();
  vh0 = mesh.add_vertex(PolyMesh.Point(0,0,0));
  vh1 = mesh.add_vertex(PolyMesh.Point(1,0,0));
  vh2 = mesh.add_vertex(PolyMesh.Point(1,1,0));
  vh3 = mesh.add_vertex(PolyMesh.Point(0,1,0));
  vh_list = [vh0, vh1, vh2, vh3];
  fh0 = mesh.add_face(vh_list);
  </code></pre>
  
  <p>This creates a single quad mesh. Then, wanting to refine the quad once, I thought to try:</p>
  
  <pre><code>vh4 = mesh.add_vertex(PolyMesh.Point(0.5,0,0));
  vh5 = mesh.add_vertex(PolyMesh.Point(0.5,1,0));
  vh_list = [vh4, vh1, vh2, vh5];
  fh1 = mesh.add_face(vh_list);
  </code></pre>
  
  <p>The above gives me a <code>complex edge</code> error. I understand from one of the other questions on SO that this is because vh_list in the second case does not define a consistent orientation wrt the first face. However, I did not want to add a new face. That is, I thought the operation would simply split fh0 at x = 0.5 and not create a new face attached to fh0 at edge index 1. Can someone say something about how this can be done? I could not find a "split_face" function in the documentation.</p>
  
  <p>Also, how do I access handles of particular edges/mesh components in Python? (I found answers only for C++.) For instance, I know that I can iterate over the edges with,</p>
  
  <pre><code>for eh in mesh.edges():
  </code></pre>
  
  <p>but how can I directly get the handle for edge 2 and use it as follows, for example?</p>
  
  <pre><code>mesh.split_edge(eh,vh5)
  </code></pre>
  
  <p>Thank you!</p>
  
  <p><strong>Edit 1</strong></p>
  
  <p>I found the function <code>split</code> in OpenMesh documentation, but it takes as input a single vertexhandle at which I can split the face. And post-splitting, it converts the mesh to a mesh of triangles. I do not want this. I want to split the quadrilateral into two quadrilaterals at x = 0.5. Thank you.</p>
  
  <p><strong>Edit 2</strong></p>
  
  <p>I tried an alternate approach: first delete fh0, and then add two new faces fh0 and fh1 based on the refinement I want. I tried doing</p>
  
  <pre><code>mesh.delete_face(fh0)
  </code></pre>
  
  <p>and Python segfaulted and exited.</p>