Target Edge Length, QuadRemeshParameters Class

Does the QuadRemeshParameters Class have a target edge length property somewhere that I haven’t noticed?


No, but you can compute TargetQuadCount like this:

private void RunScript(Mesh m, double edgeLength, ref object A)
{
  var parameters = new QuadRemeshParameters();
  var area = AreaMassProperties.Compute(m).Area;
  parameters.TargetQuadCount = Convert.ToInt32(Math.Round(area / (edgeLength * edgeLength), 0));
  parameters.AdaptiveSize = 0.0;
  parameters.AdaptiveQuadCount = false;
  A = m.QuadRemesh(parameters);
}

QuadRemesh.gh (140.2 KB)

3 Likes
def TargetQuadCountFromTargetEdgeLength( mesh, targetEdgeLength ):
    parameters =  rh.Geometry.QuadRemeshParameters()
    area = rh.Geometry.AreaMassProperties.Compute(mesh).Area
    parameters.TargetQuadCount = round( area / (targetEdgeLength * targetEdgeLength), 0 );
    return parameters.TargetQuadCount

I tried to add a Python version.

I’d really like to be able to nominate quadremesh with target length from RhinoCommon and calculating facecount from area isn’t appropriate. Was this added to Rhinocommon somewhere else or can it please be added ASAP?

Thanks,

Jon

I have a YT for this issue already. It’s a low priority at the moment while we address higher v7 priorities.

The method posted above is exactly how i calculate the target edge length behind the scenes. So it will be the same when I add it. It’ll just save you a couple of lines of code.

https://mcneel.myjetbrains.com/youtrack/issue/RH-59654

1 Like

Thanks for the reply. I hadn’t recognized this might be the case. If that is the case, I’ve no problem with computing quad count using the same technique.
I’m still having problems though. I get null mesh using rhinocommon calls (grasshopper test below). If I bake the mesh in this gh script and use the rhino command, I get a mesh that I’d like.

Is there something amiss in my settings? I also seem to get different mesh in Rhino UI version if I nominate 0.1 vs an equivalent quad count. Why in the UI do other options get disabled if you toggle between target length and quadcount if behind the scenes it computes a quadcount from mesh area?


201120 quad remesh.gh (411.9 KB)

Thanks,

Jon

Your definition has components that I don’t have but here’s an example I made awhile back for this.

“Why in the UI do other options get disabled if you toggle between target length and quadcount if behind the scenes it computes a quadcount from mesh area?”

As mentioned above, when target edge length is active, the other values are being computed automatically based on your desired target edge length.

Target Edge Length Quad Remesh (1).gh (35.0 KB)

I’m not sure why you wouldn’t have all the components, I don’t believe all are from Grasshopper.

I’d like to understand what inputs might provide a mesh. I’ve attached a 3dm file (centre mesh is to be remeshed) and an adapted version of your gh script (in particular I couldn’t use your integer division for my inputs). I get a null output and I tried a few different setting configurations.

Thanks,

Jon

201120 mesh.zip (1.5 MB)
Target Edge Length Quad Remesh (1).gh (39.7 KB)

Your part is very far from the origin. Move it to the origin and then try building your definition.

Thanks for that advice, method is working for tests so far closer to origin.