Grasshopper

algorithmic modeling for Rhino

Hi,

i'm trying to figure out, how i can intersect one curve (river) with multiple curves (streets).

but i always get the following error:

1. Error (CS0122): 'Rhino.Geometry.Curve.Curve()' is inaccessible due to its protection level (line 109)

How can i solve this?

public static OpenTK.Vector2d TopologyReaction(Rhino.Geometry.Curve riverinput, OpenTK.Vector2d parentPt, OpenTK.Vector2d newPt)
  {
    double hightDiff = _fctHDiff(parentPt, newPt);
    double slope = _fctSlope(parentPt, newPt);
    double a, b = new double();
    bool nulltest = false;
    //Curve street = Curve.CreateInterpolatedCurve(<pointList>, 0);
    Curve cv = new Curve();
    //Line street = new Line();
    
    //streetcv = NurbsCurve.CreateFromLine(street);
    
    //OpenTK.Vector2d parentPtnew = new OpenTK.Vector2d(parentPt.X, parentPt.Y);
    //OpenTK.Vector2d newPtnew = new OpenTK.Vector2d(newPt.X, newPt.Y);



    //street = new Line(parentPtnew, newPtnew);

    Rhino.Geometry.Intersect.CurveIntersections ci;
    ci = Rhino.Geometry.Intersect.Intersection.CurveCurve(riverinput, street, 0.001, 0.001);
    
    if(ci[0].PointA == null)
    {
      nulltest = true;
    }
    if(nulltest == false)
    {
      if ((slope > 2) || (newPt.X == -1.1111 && newPt.Y == -1.1111))
      {
        // -- only return this if there is no future option for finding a valip position!
        return new OpenTK.Vector2d(-1.1111, -1.1111); // theses coordinates stands for null, since Vector2d is not nullable
      }
      else
        return newPt;
    }
    else if(nulltest == true) return parentPt;
  }

Views: 1111

Replies to This Discussion

Curve cv = new Curve();

You're not allowed to construct a curve just like that. The constructor is private and you don't have access to it. You need to use one of the static Curve.CreateXXX() methods, or maybe creating some other type first like a Polyline or an Arc, then call the ToCurve or ToNurbsCurve method on it.

Thanks a lot! that helped me to get to this problem. Its kind of annother approach but with this one i also have my problems.

    double a, b = new double();
    Point3d riverStart = new Point3d (0, 0, 0);
    Point3d riverEnd = new Point3d (1000, 1000, 0);
    Point3d stparentPt = new Point3d (parentPt.X, parentPt.Y, 0);
    Point3d stnewPt = new Point3d (newPt.X, newPt.Y, 0);

    Line river = new Line(riverStart, riverEnd);
    //river.ToNurbsCurve();

    Line street = new Line(stparentPt, stnewPt);
    //street.ToNurbsCurve();


    Rhino.Geometry.Intersect.CurveIntersections ci;
    //ci = Rhino.Geometry.Intersect.Intersection.CurveCurve(river, street, 0,0001, 0,0001); // Conversion fails.
    ci = Rhino.Geometry.Intersect.Intersection.LineLine(river, street, out a, out b); // LineLine intersection dosent work

one the one hand, i cant get the conversion from a line to a curve work

on the other the LineLine intersections also dosen't work with these errors:

1. Error (CS0131): The left-hand side of an assignment must be a variable, property or indexer (line 116)

2. Error (CS0029): Cannot implicitly convert type 'Rhino.Geometry.Line' to 'Rhino.Geometry.NurbsCurve' (line 116)

3. Error (CS0029): Cannot implicitly convert type 'bool' to 'Rhino.Geometry.Intersect.CurveIntersections' (line 120)

Incidentally, constructors do not work the way you think they work. new double() and new Line() are meaningless statements, since doubles and Lines are value types. See this msdn page for an explanation of the difference between the two.

You may also want to read up on inheritance and type hierarchies. When working with RhinoCommon, it's important to understand how all the different curve types relate to each other.

There's very simple curve-like type such as Line, Circle, Arc, and Polyline. These types (except for Polyline) are value types. Value types tend to be small, pretty fast and made up of other value types such as Point3d and Plane. Ideally value types would be immutable, but unfortunately we did not do that when we designed RhinoCommon.

Rhino also has a whole family of more complicated kinds of curves. Examples of these include LineCurve, ArcCurve, NurbsCurve, PolyCurve, CurveProxy, BrepEdge and others. These types all inherit from the abstract class Curve. Abstract classes are only half-baked if you will, they may provide some functionality but they are not complete. This is why you cannot construct a Curve, in the same way that you couldn't drive around in the idea of a car. You need an actual car.

You may find the attached useful.

Works either with a common List:

Or List VS List:

BTW: With "some" lines of code more you can have that:

All demo data are internalized (cross fingers)

Attachments:

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service