Meshing a lofted polyline

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?

Thanks, --Mitch

MeshLoft.3dm (76.8 KB)

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…

It should be Tolerance as far as I can tell, and here it doesn’t seem to change anything…

Plus, if I mesh the object in Rhino, with everything zeroed out but just jagged seams and simple planes checked, the mesh is correct… --Mitch

Ugh… That’s weird.

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…

Hi Mitch,

this seems to work:

    mp=Rhino.Geometry.MeshingParameters.Coarse
    mp.SimplePlanes=True
    mp.JaggedSeams=True
    mp.GridMinCount=0
    mp.GridMaxCount=0

i have to admit, if i do not use .Coarse, it makes no sense that it does not work. I`ve tried to set almost all parameters.

c.

Thanks Clement! I had tried .Coarse as well, but I guess I didn’t have the right combination… Not exactly well documented, this one… --Mitch

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

https://github.com/mcneel/Rhino5Samples_CPP/blob/master/SampleCommands/cmdSampleCustomMeshObjects.cpp