Hi @Dongyeop_Lee,
By just evaluating the Surface
, you don’t taking the referencing BrepFace
into account.
Try this: bake your surface to Rhino, select the surface, and run the List
command. You’ll see this:
As you can see, by the reverse(1)
, the face orientation is opposite of natural surface orientation.
Also, it’s best not to reparametrize curves or surfaces if you don’t have to. The Interval
class contains methods convert to normalized parameters from interval parameters, and vise versa.
When curves and surfaces are parameterized with a [0,1] domain, both the accuracy and the precision of geometric calculations like intersections and closest points are reduced, sometimes dramatically.
There is a better approach to evaluating a surface at the center:
private void RunScript(Surface S, ref object centerPt, ref object normal)
{
Interval domain_u = S.Domain(0);
Interval domain_v = S.Domain(1);
double norm_u = domain_u.ParameterAt(0.5);
double norm_v = domain_v.ParameterAt(0.5);
Point3d cp = S.PointAt(norm_u, norm_v);
Vector3d nv = S.NormalAt(norm_u, norm_v);
centerPt = cp;
normal = nv;
}
Here is a re-factored version of your code that works more like Grasshopper’s component:
private void RunScript(Brep B, ref object centerPt, ref object normal)
{
if (null != B && 1 == B.Faces.Count)
{
BrepFace F = B.Faces[0];
Interval domain_u = F.Domain(0);
Interval domain_v = F.Domain(1);
double norm_u = domain_u.ParameterAt(0.5);
double norm_v = domain_v.ParameterAt(0.5);
Point3d cp = F.PointAt(norm_u, norm_v);
Vector3d nv = F.NormalAt(norm_u, norm_v);
if (F.OrientationIsReversed)
nv.Reverse();
centerPt = cp;
normal = nv;
}
}
Hope this helps.
– Dale