Hi.
I am working on a surface paramterization plugin in rhino6 and needs some help.
The input data of my plugin is a NURBS surface and some NURBS curves which attached on the surface.
To unfold the surface and the adhering curves, I need to discretize the raw NURBS surface into triangle mesh and discretize the raw NURBS curves into points.
Due to inconsistent sampling accuracy in discretization, some points are not attached to the mesh surface.
Is there any way to get the triangle indices of all those point?
The following image is the effect I want to achieve
I know there is built in Pushup() and Pullback(). but they can not satisfied my demands since I need to use customed surface parameterization algorithm to minimize map distortion.
You can use Mesh.ClosestPoint or Mesh.ClosestMeshPoint. Both of which can return the index of the mesh face that is closest to a given test point. Note that the former has multiple overloads.
Thank you for your reply.
Could you please offer me a C++ code example? I am a newbie of Rhino development and not familiar with RhinoCommon. The algorithm of the plugin is implement through OpenNurbs largely.
update:
I have look intoGetClosestPoint() in opennurbs_mesh.h, It seems that it can only find a B according to A which A and B is both need on the mesh.
the points from nurbs curves and the mesh from nurbs surface are independent of each other. which means those points is NOT on the mesh. it has a slightly offset from mesh surface.
what I want to do is to make it attach on the mesh surface,like a texture attached on the mesh.
In the Rhino C++ SDK, you might have a look at the RhinoPullCurveToMesh function which makes a polyline approximation of the input curve and gets the closest point on the mesh for each point on the mesh. Then it “connects the points” so that you have a polyline on the mesh. See rhinoSdkMeshUtilities.h for details.
You can also do a closest point calculation using ON_MeshTree::GetClosestPoint. I’ve attached an example.