Can anyone tell me why meshing this lofted polyline gives such a wrong result and what mesh parameters to use to get it to make one quad (or at worst two tris) per brep face?
import rhinoscriptsyntax as rs
import Rhino, copy
import scriptcontext as sc
def TestMeshLoft():
plID=rs.GetObject("Select polyline",4,True)
pl=sc.doc.Objects.Find(plID).Geometry
plCopy=copy.copy(pl)
plCopy.Translate(Rhino.Geometry.Vector3d(0,0,10))
np=Rhino.Geometry.Point3d.Unset
sl=Rhino.Geometry.LoftType.Straight
mp=Rhino.Geometry.MeshingParameters()
mp.SimplePlanes=True
mp.JaggedSeams=True
loft=Rhino.Geometry.Brep.CreateFromLoft([pl,plCopy],np,np,sl,False)
#loft is a list of breps
for brep in loft:
sc.doc.Objects.AddBrep(brep)
#brep should be a set of joined planar faces
meshlist=Rhino.Geometry.Mesh.CreateFromBrep(brep,mp)
for mesh in meshlist:
sc.doc.Objects.AddMesh(mesh)
sc.doc.Views.Redraw()
TestMeshLoft()
It behaves the same in Rhino itself and if you set minimum distance to surface to a small-ish value (0.01) on the mesh parameters the problem goes away. I suppose this case can be added to the list of weird meshing behaviour that was discussed recently.
In code, I think the “minimum distance to surface” that you see in the Mesh dialog is either Tolerance, MinimumTolerance or RelativeTolerance. The naming is not quite consistent with the names in the dialog…
I’m not at my workstation right now, but there are some subtle things about the MeshingParameters and how they relate to the dialog. I’ll see if I can get some more details tomorrow on this. I know it took us some time to figure out what each parameter does…
If you look in the code example below for meshing in C++, you find the following info mapping the properties of the meshing parameters to the names used in the dialog:
m_relative_tolerance = 0.1; // Density
m_refine_angle = 0.0; // Maximum angle (radians)
m_grid_aspect_ratio = 0.0; // Maximum aspect radio
m_min_edge_length = 0.0001; // Minimum edge length
m_max_edge_length = 0.3; // Maximum edge length
m_tolerance = 0.0; // Maximum distance, edge to surface
m_grid_min_count = 0; // Minimum initial grid quads
m_bRefine = true; // Refine mesh
m_texture_range = 2; // Pack textures