Plugin to control NURBS to mesh curve divisions


#1

I’ve written a few plugins using C# and I’m familiar with Python, however I find the documentation in the SDK very difficult to understand. My previous plugins that I’ve written are largely based on modifications to collections of sample code.

Using Rhino3d, I’d like more control over how it meshes curves. I’d like to control the number of mesh vertex divisions on a curve/arc using my algorithm based on the angle and radius of the curve. I actually already have a plugin that calculates the number of divisions (range) to use.

Currently I am forced to export it into ANSYS APDL (where I can directly specify divisions by selecting each line), meshing, then importing back to rhino.


(Dale Fugier) #2

Rhino.Geometry.Curve.ToPolyline gives you much of what you describe. Have you tried it?


#3

Will that actually affect the mesher? For example, if I have a cylinder and want to control how many mesh divisions going around.


(Menno Deij - van Rijswijk) #4

Why not extract curves by iso or by section, then evaluate/divide these curves and build the mesh by hand?


#5

One part may consist of 1000 mesh facets. My entire model may be 100000 facets. It becomes very tedious, not practical and error prone. That’s the whole reason for having a mesher.


(Menno Deij - van Rijswijk) #6

Sorry, i see that my message was unclear. All of the actions are to be performed by code, not by a user (this is the Developer category after all!). Building a mesh “by hand” in code means that you know the mesh vertices and how they form mesh faces. The vertices can be obtained from the curves, also gotten in code from sectioning or isocurve extraction.


#7

Ah, thanks for the clarification. I had interpreted “by hand” actually “by hand” versus by code. My initial approach was more towards any special API functions for the mesher. I could attempt to mesh by code for simple cases, but when I have a complex object I don’t think it would produce a good mesh. I assume that Rhino’s mesher has many advanced functions to produce a “better/smarter” mesh. I would be trying to “re-invent the wheel” in a sense where all I really want to do is to tweak it a little


(Menno Deij - van Rijswijk) #8

I see. If you want to control the outcome of a meshing, you need to set the MeshingParameters and obtain a mesh with those. The following code snippet should tell you more. The values do not really make sense, you need to tune these to your case.

The comments show the name of the parameter in the Mesh dialog (use the Mesh command then click “Detailed Controls”).

MeshingParameters mp = new MeshingParameters();
mp.RelativeTolerance = 0; // Density
mp.GridAngle = RhinoMath.ToRadians(5); // maximum angle
mp.GridAspectRation = 3; // Maximum aspect ratio
mp.MinimumEdgeLength = 1; // Minimum Edge Length
mp.MaximumEdgeLength = 5; // Maximum Edge Length
mp.Tolerance = 0.1; // Max distance, edge to surface
mp.GridMinCount = 50; // Minimum initial grid quads
mp.RefineGrid = true; // Refine grid
mp.JaggedSeams = false; // jagged seams
mp.SimplePlanes = true; // simple planes

Brep b; // a (poly)surface defined elsewhere
Mesh[] m = Mesh.CreateFromBrep(b, mp); //creates the mesh(es) from the brep


Failed to create closed mesh with Mesh.CreateFromBrep(brep, meshing_params) +.., while sucessfull with rhino command _Mesh
#9

This seems the same as the meshing parameters I get in the GUI. I had hopped the API would provide more options. Is there a way to some how “mark” a curve to tell the mesher to put a vertex there but not any more? For example adding a knot.


(Menno Deij - van Rijswijk) #10

Not to my knowledge. You can maybe modify the underlying geometry - the mesher puts gridlines over each surface seam. Other than that I’m afraid this is it…


(Dale Fugier) #11

Sorry, our mesher does not have such a feature.