Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intersect_Mathematical.ghx BrepPlaneIntersection Issue #18

Open
Guanda0120 opened this issue Sep 8, 2023 · 0 comments
Open

Intersect_Mathematical.ghx BrepPlaneIntersection Issue #18

Guanda0120 opened this issue Sep 8, 2023 · 0 comments

Comments

@Guanda0120
Copy link

I found that the BrepPlaneIntersection part may not generate the same result as original Grasshopper. Original Grasshopper generate one line. And gh-sharp-master may generate two or more. I found we can join curves after BrepPlane to fix this problem.
The Commond Code BrepPlaneIntersection of in gh-sharp-master/src/Intersect_Mathematical.ghx is as follow:

private void RunScript(Brep B, Plane P, ref object C, ref object POut)
  {
    //Component written by @bava-kumaravel
    //Solve intersection between a brep B and an infinite plane P and
    //return list of section curves C and list of intersection points POut

    //Define arrays to hold the section curves and intersection points
    Curve[] curves = new Curve[0];
    Point3d[] points = new Point3d[0];

    //Define tolerance as the Model Space Absolute Tolerance
    double tol = doc.ModelAbsoluteTolerance;

    //Perform intersection
    bool success = Rhino.Geometry.Intersect.Intersection.BrepPlane(
      B, P, tol, out curves, out points);

    //Outputs
    if(success){
      C = curves;
      POut = points;
    }

My Code is as follow

private void RunScript(Brep B, Plane P, ref object C, ref object POut)
  {
    //Component written by @bava-kumaravel
    //Solve intersection between a brep B and an infinite plane P and
    //return list of section curves C and list of intersection points POut

    //Define arrays to hold the section curves and intersection points
    Curve[] curves = new Curve[0];
    Point3d[] points = new Point3d[0];

    //Define tolerance as the Model Space Absolute Tolerance
    double tol = doc.ModelAbsoluteTolerance;

    //Perform intersection
    bool success = Rhino.Geometry.Intersect.Intersection.BrepPlane(
      B, P, tol, out curves, out points);

    // Join Curves
    if (success && curves.Length > 1) 
    {
          curves = Curve.JoinCurves(curves, tol);
     }

    //Outputs
    if(success){
      C = curves;
      POut = points;
    }

In addition, I would like to express my sincere gratitude to Professor Luis for their assistance in my programming learning journey. Your courses have been extremely beneficial to me.

IssueBrepPlaneIntersect.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant