How to understand and solve the ON_CurveProxy problem in data conversion

I was using the IsValidTopology() function when ON_CurveProxy::IsValid returned an error, telling me that m_real_curve was null.
This is how I created the edge and curve in brep.
ON_Curve* onCurve3d = nullptr;
ConvertCurve(ggpCurve3d, &onCurve3d);
int curve3dIndex =brep.AddEdgeCurve(onCurve3d);
onEdge.m_c3i = curve3dIndex;
What should we do to make the realcurve have a value

Hi @JJerry,

You have not provided much code to go on. But I think you want to do this:

ON_Curve* pCurve = ConvertCurve();
if (pCurve)
{
  int c3i = pBrep->AddEdgeCurve(pCurve ); // Brep now owns curve
  pEdge->m_c3i = c3i;
  pEdge->SetProxyCurve(pCurve);
}

– Dale

Another problem is that many edges and trims have only one valid point id, and the other point id is invalid (-1 or all 0).

Hi @JJerry,

Here are a couple of SDK samples that demonstrate how to build Breps from scratch.

Even though these samples are including with other Rhino SDK samples, the code is just openNURBS.

SampleFaceWithHole

SampleTrimmedPlane

SampleTwistedCube

Hope this helps.

– Dale