I need to be able to project curves onto a brep, but I do not function any SDK function. Is there a solution for this?
It is true that the Rhino SDK does not, currently have a function that will project a curve onto a brep. But, using some of the existing SDK functions, you can write your own function without too much effort.
To project a curve onto a brep, you need to do the following:
The following sample code demonstrates how one might write such a function.
/*
Description:
Projects a curve onto a surface or polysurface
Parameters:
brep - [in] The brep to project the curve onto.
curve - [in] The curve to project.
dir - [in] The direction of the projection.
tol - [in] The intersection tolerance.
output_curves - [out] The output curves.
NOTE, the caller is responsible
for destroying these curves.
Returns:
true if successful.
false if unsuccessful.
*/
bool ProjectCurveToBrep(
const ON_Brep& brep,
const ON_Curve& curve,
const ON_3dVector& dir,
double tolerance,
ON_SimpleArray<ON_Curve*>& output_curves
)
{
ON_3dVector n = dir;
if( !n.Unitize() )
return false;
ON_BoundingBox bbox = brep.BoundingBox();
bbox.Union( curve.BoundingBox() );
ON_Surface* pExtrusion = RhinoExtrudeCurveStraight( &curve, dir, bbox.Diagonal().Length() );
if( 0 == pExtrusion )
return false;
ON_Brep* pBrep = ON_Brep::New();
pBrep->Create( pExtrusion );
BOOL rc = RhinoIntersectBreps( *pBrep, brep, tolerance, output_curves );
delete pBrep; // Don't leak...
return ( rc ) ? true : false;
}