Hi there,

A question about function of “point in trim” which is using parametric point coordinates and B-Rep data to classify a point. What is the basic algorithm of this function and how is the accuracy? Maybe any reference?

Best wishes,

Eric

Hi there,

A question about function of “point in trim” which is using parametric point coordinates and B-Rep data to classify a point. What is the basic algorithm of this function and how is the accuracy? Maybe any reference?

Best wishes,

Eric

Hi Eric,

Can you provide a little more of a clue as to what function you have a question about? Perhaps some sample code?

– Dale

Hi Dale,

Thanks for your reply. The function “Point In Trim” is a predefined component in Grasshopper, which has two inputs and one output. The figure attached is the one I discussed. “S” is input of B-rep surface, “P” is input of uv-coordinates, and “I” will be a boolean output giving true for inside point or false for outside point.

Since this component is a very important procedure in my research, so I want to confirm the algorithm for this component and its accuracy. Or any reference paper for this algorithm?

Best,

Eric

Hi Eric,

Check the brepFace.IsPointOnFace method:

```
import Rhino
brepFace = brep.Faces[0]
pointBrepFaceRelationship = brepFace.IsPointOnFace(u,v)
if pointBrepFaceRelationship == Rhino.Geometry.PointFaceRelation.Interior:
print True
elif pointBrepFaceRelationship == Rhino.Geometry.PointFaceRelation.Exterior:
print False
elif pointBrepFaceRelationship == Rhino.Geometry.PointFaceRelation.Boundary:
print 2 # coincide
```

Yep, that’s it…

Hi Djordje,

So this “brepFace.IsPointOnFace(u,v)” is the key function to identify the interior parametric coordinated point. But how does it work?

It’s easy to evaluate a point on untrimmed NURBS surface with control points and shape functions. However, it’s difficult to identify whether this point on a retained domain of a trimmed NURBS. Do you use the loops of B-rep data to identify the interior points? How do you control the accuracy if a point is very close to the trimming curve?

Best,

Eric

Hi Eric,

If you are asking which Rhino c++ SDK method does RhinoCommon IsPointOnFace method calls, then I am afraid I do not know the answer. Dale and Rhino developers can help you with that and the very principle on which this method works.

Hi Djordje,

Yes. I want to make sure the algorithm, or the order of accuracy of this algorithm at least. So I could convince people that Grasshopper 3D is a robust and accurate tool for our research.

Best,

Chenglong

Each edge has a tolerance value. If the point is within that distance of an edge, it is said to be on the boundary. The algorithm first looks to see if any edges are close enough. If not, it just shoots a ray from the uv point through the 2d trimming curves and counts the crossings.

You should be able to trust the answer when it is either “interior” or “exterior” and, depending on what your requirements are, do some more testing when the answer “boundary”

The best way to determine if this is accurate enough for your purposes is to make up some questionable cases and see if the answer is what you expect.

Chuck Welsh

Robert McNeel and Associates