Get seam of curve


#1

Hi,

I need get the seam point of a curve,

I need this point because after a process, this point is moved, so I need set the seam point initial.

To get the point I use

Double startSeam = perimeterOffset.Domain.Min

and to set I use

perimeterOffset.ChangeClosedCurveSeam(startSeam);

But it isn’t work.

I use c# with rhinocommon and visual studio 2010


(Dale Fugier) #2

Does this help?

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  GetObject go = new GetObject();
  go.SetCommandPrompt("Select closed curve for seam adjustment");
  go.GeometryFilter = ObjectType.Curve;
  go.GeometryAttributeFilter = GeometryAttributeFilter.ClosedCurve;
  go.SubObjectSelect = false;
  go.Get();
  if (go.CommandResult() != Result.Success)
    return go.CommandResult();

  Curve curve = go.Object(0).Curve();
  if (null == curve)
    return Result.Failure;

  GetPoint gp = new GetPoint();
  gp.SetCommandPrompt("New seam location");
  gp.Constrain(curve, false);
  gp.Get();
  if (gp.CommandResult() != Result.Success)
    return gp.CommandResult();

  Point3d point = gp.Point();

  Curve new_curve = curve.DuplicateCurve();
  double t = Rhino.RhinoMath.UnsetValue;
  if (new_curve.ClosestPoint(point, out t))
  {
    if (new_curve.ChangeClosedCurveSeam(t))
      doc.Objects.Replace(go.Object(0), new_curve);
  }

  return Result.Success;
}

#3

No,

I want to get something how this image

From a contour, I’m nesting and linking offsets. In this image all seam points of each nested offset are ok.

But if I apply a smoothing function I get this

So, my idea is get the seam point before apply de smoothing function, and after restore the point.


(Willem Derks) #4

Hi Manolo,

FWIW:
Ccould it be the smoothing function reparameterizes the curves?
I’m not sure what “perimeterOffset.Domain.Min” returns, but is that is a parameter, then it will not be of much use if the curve was indeed reparameterized.
In that case I guess you need to store the 3Dpoint location of the original seam and evaluate the parameter of the smooth curve at that 3D point location to set the new seam parameter.

-Willem


(Dale Fugier) #5

Wow, not sure how I was supposed to connect your original question with these images. Would have been nice to see these from the start.

But even these images don’t give us much to go on. But Willem’s suggestion is as good as any (at this point).


#6

Hi again,

I don’t know how store the 3Dpoint location of the original seam neither set the seam parameter after smoothing funcion.

The function to smooth the curve isn’t mine, and I don’t know that it does exactly, but, when I apply the function the seam is relocated, Inside the code, I haven’t seen nothing about moving the seam point.


#7

Any idea?


(Dale Fugier) #8

Try this:

1.) Get the seam location, which on a closed curve is Domain.Min

2.) Evaluate the parameter to obtain a 3D point - Curve.PointAt

3.) Smooth your curve

4.) Find the closest point on the smooth curve to your 3D point - Curve.ClosestPoint

5.) Modify the seam (using my example) with the results of the closest point calculation.


#9

Thank you very much.

I didn’t know how obtain the 3dpoint (step 2) and set the new seam point (step 5)


#10

This will probably perform 1) and 2) internally but for the sake of code readability you could just get the PointAtStart or PointAtEnd properties of the curve.