Sub D Chamfer Vertex

Hi,

1.How correctly I can chamfer vertex in subD?

When I do following loop within all vertices in SubD I get error:
Solution exception:Index was outside the bounds of the array.

2.I would like to ask about also about SubDType as I in the following script only Rhino.Geometry.SubD.SubDType.QuadCatmullClark works other one gives an error.

   public class Subdivide : GH_Component {

    public Rhino.Geometry.SubD.InteriorCreaseOption[] Crease = new[]
    {
        Rhino.Geometry.SubD.InteriorCreaseOption.Unset,
        Rhino.Geometry.SubD.InteriorCreaseOption.AtMeshCrease,
        Rhino.Geometry.SubD.InteriorCreaseOption.AtMeshEdge,
        Rhino.Geometry.SubD.InteriorCreaseOption.None
    };

    public Rhino.Geometry.SubD.SubDType[] type = new[]
    {
        Rhino.Geometry.SubD.SubDType.Unset,
        Rhino.Geometry.SubD.SubDType.Custom,
        Rhino.Geometry.SubD.SubDType.CustomQuad,
        Rhino.Geometry.SubD.SubDType.CustomTri,
        Rhino.Geometry.SubD.SubDType.TriLoopWarren,
        Rhino.Geometry.SubD.SubDType.QuadCatmullClark
    };

    public Rhino.Geometry.DistancingMode[] DistanceModes = new[]
    {
        Rhino.Geometry.DistancingMode.Linear,
        Rhino.Geometry.DistancingMode.LinearFromEnd,
        Rhino.Geometry.DistancingMode.Ratio,
        Rhino.Geometry.DistancingMode.RatioFromEnd,
        Rhino.Geometry.DistancingMode.Undefined
    };

    public Subdivide()
      : base("Subdivide", "Subdivide",
          "Description",
          "SubD", "Sub") {
    }


    protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
    {
        pManager.AddMeshParameter("Mesh", "M", "Mesh", GH_ParamAccess.item);
        pManager.AddIntegerParameter("N", "N", "N", GH_ParamAccess.item,1);
        pManager.AddIntegerParameter("N", "N", "N", GH_ParamAccess.item, 1);
        pManager.AddIntegerParameter("N", "N", "N", GH_ParamAccess.item, 5);
        pManager.AddIntegerParameter("N", "N", "N", GH_ParamAccess.item, 5);
        pManager.AddNumberParameter("Distance", "D", "Chamfer Distance", GH_ParamAccess.item, 1);
    }


    protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) {
        pManager.AddMeshParameter("Mesh", "M", "Mesh", GH_ParamAccess.item);
    }


    protected override void SolveInstance(IGH_DataAccess DA) {

        //Input
        Mesh mesh = new Mesh();
        DA.GetData(0, ref mesh);

        int n = 0;
        DA.GetData(1, ref n);
        n %= 4;

        int divisions = 0;
        DA.GetData(2, ref divisions);

        int t = 0;
        DA.GetData(3, ref t);
        n %= 6;

        int d = 0;
        DA.GetData(4, ref d);
        n %= 5;

        double dist = 1;
        DA.GetData(5, ref dist);

        //Solution


        Rhino.Geometry.SubD sub = Rhino.Geometry.SubD.CreateFromMesh(mesh, Crease[n]);

       //How to make this right?
        for (int i = 0; i < sub.Vertices.Count; i++)
                   sub.ChamferVertex(i, DistanceModes[d],dist);
       
        

        //Output
        DA.SetData(0,sub.ToLimitSurfaceMesh(divisions,type[t]));

    }
    }

@dalelear this one is for you as well-

@Trav Do you know the answer to this off the top of your head? If not, I can start digging around in the .NET wrappers.

@dalelear this post was from 2017. The .Net SubD classes have changed considerably since its original authoring. With that said there is nothing that stands out to me right away that is in the current SubD class or SubDVertex class that would do a chamfer. Perhaps @Jussi_Aaltonen could expose some of the bevel functionality to RhinoCommon?

Yes, I will eventually do that @Trav. You can create YT for me so it won’t get forgotten.

thanks @Jussi_Aaltonen!

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

1 Like