I want write a C++ function to find some breps contained in a curve.

In this example I want the “3” and “4” breps.

can somebody give me some ideas how write this function,thanks very much

the attachment has a test 3dm file.

查找曲线包围的曲面.rar (802.7 KB)

An simple approach is to just sample a number of points along the edges of the Brep and see if their distances are within some tolerance of the curve. With this approach, a function like this will come in handy:

```
bool IsPointOnCurve(
const ON_Curve& curve,
const ON_3dPoint& point,
double tolerance
)
{
bool rc = false;
if (curve.IsValid() && point.IsValid())
{
if (tolerance < ON_ZERO_TOLERANCE)
tolerance = ON_ZERO_TOLERANCE;
double curve_t = 0.0;
if (curve.GetClosestPoint(point, &curve_t))
{
ON_3dPoint curve_pt;
if(curve.EvPoint(curve_t, curve_pt))
{
if (point.DistanceTo(curve_pt) <= tolerance)
rc = true;
}
}
}
return rc;
}
```

dale:

in this example ,the edge between 3 brep and 4 brep is not on the curve . so still can’t use you approach to ajust 3 brep and 4 brep are contained in the curve

dale:

please see my problem,thanks

Rhino does not have a ‘magic’ SDK function that will solve this problem for you. You are going to have to come up with and implement your own algorithm to solve this. My quick solution was to sample points on the Brep edges and see if they all fall within some reasonable tolerance of the curve. But if you feel this is inadequate, then you will have to come up with something else - sorry.

– Dale