Hi guys!
As you can read here seems that Rhino can’t calc surfaces intersections properly, in some cases.
As suggested, i would like to apply something like “MakeUniform” command to a surface, but using C# code.
I tried to search something useful in the RhinoCommon SDK but i found nothing…
Can you help me?
Thanks!
Hi @software_comas,
See if this works for you:
/// <summary>
/// Changes a surface so each control point affects the surface exactly the same way.
/// Makes the surface's knot vectors uniform without changing the control point locations.
/// This will change the surface's shape slightly.
/// </summary>
/// <param name="srf">The surface.</param>
/// <param name="direction">The direction, where 0 = U, 1 = V, 2 = Both.</param>
public static bool MakeSurfaceUniform(NurbsSurface srf, int direction = 2)
{
if (srf == null || direction < 0 || direction > 2)
return false;
for (int dir = 0; dir < 2; dir++)
{
if (dir == 0 && direction == 1)
continue;
else if (dir == 1 && direction == 0)
continue;
var index = 0.0;
var srf_knots = (dir == 0) ? srf.KnotsU : srf.KnotsV;
var old_knot = srf_knots[0];
srf_knots[0] = index;
for (var ki = 1; ki < srf_knots.Count; ki++)
{
var knot = srf_knots[ki];
if (Math.Abs(knot - old_knot) < RhinoMath.ZeroTolerance)
{
if (ki < srf.Degree(dir) || ki >= srf_knots.Count - srf.Degree(dir))
{
srf_knots[ki] = index;
continue;
}
}
index += 1.0;
srf_knots[ki] = index;
old_knot = knot;
}
}
return true;
}
– Dale
如果是brepface呢?或者是trimmed surface
你好 Dale:
我现在有一些Trimmed Surface,(实际是BrepFace),请看下面的图
怎么样才能在Trimmed Surface上实现这个功能呢?
(图中的Rebuild Surface在LunchBox中,但是会被转换成Untrimmed Surface)
补充:请忽略图中的两张曲面,实际有5个点,这只是效果展示