MeshLib
MeshLib copied to clipboard
curve offset on the surface
Hi, I found that Meshlib has the concept of offset, but it applies to mesh.
I have a curve made of a series of points, and that curve is attached to the Mesh surface. Does Meshlib have any methods to implement the effect shown in the image?
.
Hello! Can you please show what is desired input and output?
The input is a curve made of a series of points, and the curve is made of line segments, and the line segments are made of two adjacent points. The input is the same as the output.
I guess @czc98 means a 3d curve offset constrained to the mesh surface. In this case, this recent Siggraph paper on winding numbers on discrete surfaces could come in handy: https://nzfeng.github.io/research/WNoDS/index.html
Curve 1 moves d distance along the surface to get curve 2.
https://ieeexplore.ieee.org/document/4751993 I don't know if this paper will work.
I guess @czc98 means a 3d curve offset constrained to the mesh surface. In this case, this recent Siggraph paper on winding numbers on discrete surfaces could come in handy: https://nzfeng.github.io/research/WNoDS/index.html
Thanks for one more great reference. But as far as I can see this paper deals with a set of closed curves on a surface (or closed curves with small gaps), but not completely open curves as in your example.
What we can easily do is to draw a closed curved offset on fixed distance along the surface around your input curve. And you will select some part on offset curve by yourself.
I guess @czc98 means a 3d curve offset constrained to the mesh surface. In this case, this recent Siggraph paper on winding numbers on discrete surfaces could come in handy: https://nzfeng.github.io/research/WNoDS/index.html
Thanks for one more great reference. But as far as I can see this paper deals with a set of closed curves on a surface (or closed curves with small gaps), but not completely open curves as in your example.
What we can easily do is to draw a closed curved offset on fixed distance along the surface around your input curve. And you will select some part on offset curve by yourself.
In fact, all I need is a closed curve offset. The picture is just an explanation.
Is there any way in Meshlib to do that?
Thanks for one more great reference. But as far as I can see this paper deals with a set of closed curves on a surface (or closed curves with small gaps), but not completely open curves as in your example.
I thought it could be relevant for bowties removal when an open curve offset creates self-intersections.
This task can be solved this way:
- Calculate surface distances for vertices near the path: https://github.com/MeshInspector/MeshLib/blob/master/source/MRMesh/MRSurfaceDistance.h
- Extract iso-lines of found distance field: https://github.com/MeshInspector/MeshLib/blob/7f950aebf4cf5e0bff7e1cf189b01b26bfc35d7d/source/MRMesh/MRExtractIsolines.h#L15-L17
You can find example code in implementation of this function: https://github.com/MeshInspector/MeshLib/blob/7f950aebf4cf5e0bff7e1cf189b01b26bfc35d7d/source/MRMesh/MRToolPath.h#L162-L165
function
This task can be solved this way:
- Calculate surface distances for vertices near the path: https://github.com/MeshInspector/MeshLib/blob/master/source/MRMesh/MRSurfaceDistance.h
- Extract iso-lines of found distance field: https://github.com/MeshInspector/MeshLib/blob/7f950aebf4cf5e0bff7e1cf189b01b26bfc35d7d/source/MRMesh/MRExtractIsolines.h#L15-L17
You can find example code in implementation of this function:
https://github.com/MeshInspector/MeshLib/blob/7f950aebf4cf5e0bff7e1cf189b01b26bfc35d7d/source/MRMesh/MRToolPath.h#L162-L165
I'm confused about the MR::computeSurfaceDistances function. It seems to apply only to line segments, not to curves (collections of line segments).
https://github.com/MeshInspector/MeshLib/blob/7f950aebf4cf5e0bff7e1cf189b01b26bfc35d7d/source/MRMesh/MRToolPath.cpp#L1588-L1595
startVerticesWithDists
here is vertices that are neighbors with original curve with values equal to distance to the curve.
So:
- You find all neighbor vertices to original curve
- Make Polyline3 from the curve
- Fill up
startVerticesWithDists
like here https://github.com/MeshInspector/MeshLib/blob/7f950aebf4cf5e0bff7e1cf189b01b26bfc35d7d/source/MRMesh/MRToolPath.cpp#L1564-L1586 - Then do this https://github.com/MeshInspector/MeshLib/blob/7f950aebf4cf5e0bff7e1cf189b01b26bfc35d7d/source/MRMesh/MRToolPath.cpp#L1588-L1595
Whether points on a curve are required to be vertices?
They are not, but you need to manually setup distances in the vertices closest to the curve (as Grantim explained above) before calling computeSurfaceDistances
. Also this method is limited to offsets larger than edge length.
Alternatively, you can cut the mesh along the curve using cutMesh
function. This will introduce vertices and edges in the mesh, coinciding with the curve. After that the call to computeSurfaceDistances
becomes much simpler.
They are not, but you need to manually setup distances in the vertices closest to the curve (as Grantim explained above) before calling
computeSurfaceDistances
. Also this method is limited to offsets larger than edge length.Alternatively, you can cut the mesh along the curve using
cutMesh
function. This will introduce vertices and edges in the mesh, coinciding with the curve. After that the call tocomputeSurfaceDistances
becomes much simpler.
Do I not need the dists[v] = -dists[v] operation if I use the cutMesh function? Do I just need to find the vertices adjacent to Polyline3 through a topological relationship, construct startVerticesWithDists by calculating the distance from the vertices to Polyline3, and then call the extractIsolines function?
Do I just need to find the vertices adjacent to Polyline3 through a topological relationship, construct startVerticesWithDists by calculating the distance from the vertices to Polyline3, and then call the extractIsolines function?
You need to do so. dists[v] = -dists[v]
this is needed to separate inside and outside parts of the path.
Later we will write and show the function. for simplier usage.
Do I just need to find the vertices adjacent to Polyline3 through a topological relationship, construct startVerticesWithDists by calculating the distance from the vertices to Polyline3, and then call the extractIsolines function?
You need to do so.
dists[v] = -dists[v]
this is needed to separate inside and outside parts of the path. Later we will write and show the function. for simplier usage.
Do I just need to find the vertices adjacent to Polyline3 through a topological relationship, construct startVerticesWithDists by calculating the distance from the vertices to Polyline3, and then call the extractIsolines function?
You need to do so.
dists[v] = -dists[v]
this is needed to separate inside and outside parts of the path. Later we will write and show the function. for simplier usage.
What are inside and outside?
Is it the concept in the picture?
If I have open curves,yellow Curve moves d distance along the surface to get green curve.
I can know the average curvature of the surface.Now a problem is that some points may disappear during the offset process.
How should I do it better?
Hello! Sorry for late response, we are now a bit busy with other tasks. We are going to make function to demonstrate how it works hopefully in the begining of 2024.