TransWikia.com

MeshRegion automatically merges vertices that have the same position in space

Mathematica Asked by yousuf soliman on March 9, 2021

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).

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP