1
$\begingroup$

I sometimes work with surface meshes that have self-intersections (immersions rather than embeddings). MeshRegion usually doesn't have any problems dealing with these kinds of surfaces, unless there are distinct vertices that have the same position in space. During the construction of a MeshRegion these vertices are automatically merged together (the problem remains if I import such a mesh), and this obviously messes with the combinatorics of the surface. Is there a way to disable this undesired "feature"?

Here is an example illustrating this problem:

n = 31;
uvs = Flatten[Table[{i, j}/(n - 1), {i, 0, n - 1}, {j, 0, n - 1}], 1];

immersion[{u_, v_}] := {Cos[2 \[Pi] u], Sin[2 \[Pi] u], v/4};
cylinderpts = immersion /@ uvs;

foldoverimmersion[{u_, v_}] := {Cos[1/4 \[Pi] (1 + 6 u)]/(
   1 + Sin[1/4 \[Pi] (1 + 6 u)]^2), (
   Cos[1/4 \[Pi] (1 + 6 u)] Sin[1/4 \[Pi] (1 + 6 u)])/(
   1 + Sin[1/4 \[Pi] (1 + 6 u)]^2), v/4};
foldoverpts = foldoverimmersion /@ uvs;

idx[{i_, j_}] := n (i - 1) + j;
faces = Map[idx, 
   Flatten[Table[{{{i, j}, {i + 1, j}, {i, j + 1}}, {{i + 1, 
        j}, {i + 1, j + 1}, {i, j + 1}}}, {i, 1, n - 1}, {j, 1, 
      n - 1}], 2], {2}];
meshfaces = Polygon /@ faces;

parameterM = MeshRegion[uvs, meshfaces]
cylinderM = MeshRegion[cylinderpts, meshfaces]
foldoverM = MeshRegion[foldoverpts, meshfaces]

MeshRegion automatically merges nearby vertices

The meshes parameterM, cylinderM, and foldoverM are constructed using the same list of faces, but running MeshCellCount yields

{961, 2760, 1800}
{930, 2730, 1800}
{930, 2730, 1800}

It might seem reasonable that the nearby vertices should be merged for the cylinder. On the other hand, the example where I extruded part of a lemniscate (foldoverM) the vertices are only merged if the grid width is divisible by 6 (since the parameterization I use has self intersections at u=1/6 and u=5/6).

$\endgroup$
10
  • $\begingroup$ The mesh cell count is identical. But it make sense, that the count of edges and points is less when you connect faces and points. $\endgroup$ – Daniel Huber Oct 20 '20 at 10:14
  • $\begingroup$ I didn’t connect the faces and points (the number of input vertices is the same). It is strange that the geometry of the surface (vertex positions) changes the topology (faces/combinatorics) of the underlying mesh... if I take a piece of paper and fold it in half it doesn’t collapse into an unfolded piece of paper of half the size (MeshRegion will collapse the paper if the the triangulation is symmetric across the seam). $\endgroup$ – yousuf soliman Oct 20 '20 at 15:38
  • $\begingroup$ Hi, am I mistaken, if I think that at the "seam", where you connect left side of the mesh to the right side to form a cylinder, you are identifying edges and vertices. Therefore, their number will be reduced. Similar thing with the foldover. $\endgroup$ – Daniel Huber Oct 20 '20 at 16:05
  • $\begingroup$ In the description of the faces that I give I am not explicitly identifying the vertices and edges, and I want to make sure that MeshRegion does not automatically identify them based on their vertex positions. I guess another way to ask the question (which may help me understand the general case) is to ask how would I represent a cylinder with a seam (ofc, without changing the positions)? $\endgroup$ – yousuf soliman Oct 20 '20 at 16:16
  • $\begingroup$ If I set n=5 and look at "cylinderpts" then there are 5 duplicated points. If you do not want to "close" the cylinder ", you may e.g. say: immersion[{u_, v_}] := {Cos[2 [Pi] u 0.95], Sin[2 [Pi] u], v/4}; $\endgroup$ – Daniel Huber Oct 20 '20 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.