Get objects in a boundary, is it possible?



Hi guys. I have a pointcloud with thousands points. Now I want to get some points in a regoin such as a boundary object. I do not want to do it by hand, because I have to do it thousand times. Is there any method I can use in rhinocommon or ? I have check the objectTable object, it has a boundary property for all objects. I wonder If it is possible to get object by specify a certain boundary object, then we can get all objects in the boundary.
Any response is appricated.


Would Brep.IsPointInside or grasshopper PointsInBrep do what you want?

RhinoCommon method

Or using GrassHopper:

// Rolf


Thanks RIL. I checked that method. But the problem is if the number of the points more than 100000, grasshopper maybe crash. And the method takes too long time to finish my job.


If you want to check for inclusion in a simple Box or Sphere you can make a very fast inclusion test yourself with a simple script:

    // Sphere: Inputs: Points (InputPoints) and a sphere center C and a radius R
    var boolfilter  = new bool[InputPoints.Count]
    for (var i=0; i<InputPoints.Count; i++)
         boolfilter[i] = C.DistanceTo(InputPoints[i]) <= R; // true or false
    A = boolfilter; // Output. Use Dispatch to extract true-points (true = inside sphere)

A box aligned with World axes is also simple to code. If you use array (bool[]) or Point3d[] directly) for the results you can use Parallel.For, but it will probably be fast enough even without threading.


Thanks RIL. Actually what you show is ok for most of the cases. But you did not get what I really care. There are too many points, so I do not wanna loop all the points. I just want to find a fast way to get the point I care about. In a small scope. Maybe less then 1000 or less. Then I can save a lot of time. If each step I have to loop all millions of points. My computer can not bear. And it crashed several times.


When you have more than ten million points then (perhaps) you will have “too many”. Point inclusion for a simple Sphere or a World aligned Box will take only a few ms (2-5 ms) if you make your own script.

if you still would have any problems with performance with the script approach you can use RTree to make a first “extraction” out of the cloud and so reduce the number of points to test (for a Box) and cut the time even more, but I’d guess that you would reduce the execution time only for a sphere in that case. if even that.

Less than 5 ms is “no time”. 100,000 points is a problem only for the std Brep.IsPointInside, probably because it has to test for any shape of the Brep.

// Rolf