Curve x Brep intersection problem

I am trying to write a script via ghpython that simulates refraction but am running into some unexpected errors when it comes to the intersection of lines and breps. In the images below, you can see a red surface which is the source (the surface is divided to get 25 points, and “light” is emitted normal to the surface). The blue is the medium that refracts. And the two lines represents the light- only 2 of the 25 had issues. My overall strategy is to explode the medium to get its brepfaces, then intersect with a line (which is converted ToNurbsCurve()) and pick the closest point from the start of the line to evaluate refraction. When these two lines are intersected with the medium, points are generated for the flat back brepface, but none for the wavy brepface. Why is this happening and how do I fix it? Even when I intersect the lines with the medium (unexploded) in Rhino, only intersection points on the back a generated.

Better yet, maybe someone can show me how to use Rhino.Geometry.Intersect.Intersection.RayShoot(). I can generate the rays with the same inputs that generate the lines, but I am not sure how to convert Rhino.Geometry.BrepFace to geometry: IEnumerable[GeometryBase].


180111 Intersection Problem.3dm (94.0 KB)

Thanks,

Lawrence Yun

Any ideas? I’m guessing it has to do with the number of control points in the wavy brepface. I don’t want to manipulate the shape in Rhino (to make the workflow more seamless when someone else uses the simulator), and I don’t want to rebuild it since the shape might change. That particular geometry was extruded from a 2D curve.

Notify if you think that a rather complete C# example on RayShoot matters could shed some light on your issues (But you cam’t auto translate it to P in the way that you can do it with VB).

Syntax (ray: Ray3d, geom: GeometryBase object, 1: reflexions):

Point3d hitArray = Rhino.Geometry.Intersect.Intersection.RayShoot(ray, new GeometryBase[1]{geom}, 1);

BTW: RayShoot limitations (but you can deal with these with other ways):

Thanks, I’ve looked up this page before. I’m just not sure what IEnumerable<GeometryBase> geometry is. I am currently intersecting the line (curve) with the brepface. How do I convert a brepface into GeometryBase?

IEnumerable<T> is usually any collection of data. Array, List, HashSet, Stack, Queue, … you name it, they all implement IEnumerable allowing code to easily foreach over the entire collection.

If you have a single object, you’ll have to put it into a list. In fact I recommend not putting a BrepFace directly into a collection, as a BrepFace is always part of a Brep. Ideally you’d duplicate the face, creating a brand new brep:

Brep face = originalBrep.Faces[0].DuplicateFace();
List<GeometryBase> collection = new List<GeometryBase>();
collection.Add(face);

Anyway … given the opportunity get a rather entry level C# (NO auto translation to P available: life sucks) that exploits RayShoot matters.

RayShoot_VS_Object_V23.gh (123.2 KB)
RayShoot_VS_Object_V23.3dm (255.6 KB)

  1. Breps are sampled into a GeometryBase List.
  2. A Sphere is used with points either randomly defined or “even”. From the center and for each point rays are shot (kinda a mini Death Star)
  3. A track used for placing the sphere around
  4. Hits are computed and placed into 2 Trees.
  5. GeomBase stuff is cast to Brep for taking advantage a Method for the normal in order to compute the last reflexion (optional).

Thanks for the clarification. I implemented the rayshoot method into my script and it runs much faster now. However, the intersection problem still persists.

I was able to circumvent the problem before when I intersected the brepface with a curve by rebuilding the curve with 1000 control points. But since I can’t rebuild a ray, I’m looking to solve the problem directly. As I stated before, the medium was extruded from a 2d closed curve. The curves and the wavy brepface won’t intersect in Rhino unless I insertknot. How can I insertknot via rhinocommon on a brepface (assume that the brepface may have holes or be trimmed)? Preferably in Python.

Yes, I can repeat that in Rhino6 some intersection points are missing. This is a bug in the intersector, but until it gets fixed you may just be best of converting your breps to meshes before putting them in the rayshoot collection.

Not ideal, but probably the easiest. I’ll log the intersection bug after lunch.

So will this be fixed for Rhino5? Any ideas on how to insertknot via rhinocommon?

It will not be fixed for Rhino5, because there will be no more releases for Rhino 5. It won’t be fixed for Rhino 6.0 either, we’re too close to release to start messing with the intersector. Rhino 6.x at the earliest, possibly not until Rhino 7.

http://developer.rhino3d.com/api/RhinoCommonWin/html/M_Rhino_Geometry_Collections_NurbsCurveKnotList_InsertKnot.htm

Is there any example of someone using NurbsCurveKnotList to insert knots on a surface? Why is there no insertknot() method? All I want to do is insertknot (Automatically, Midpoint=Yes, Symmetrical=No, Direction=Both) via rhinocommon.

For inserting knots into nurbs surfaces you have to access the KnotsU or KnotsV properties of said surface. Then you get an instance of the NurbsSurfaceKnotList class which has two methods for inserting knots.

I put a bug on YouTrack