Hello,
I have a piece of C++ code that’s being stubborn. The code is supposed to open a Rhino .3dm and read all mesh, curve, and point data. It worked last month when I compiled and ran it last, but now it’s not working. I’m not sure what changed.
When I run it now, I’m unable to cast the ON_ModelComponent objects to ON_ModelGeometryComponent. Digging deeper, it looks like Cast calls IsKindOf to see if the cast is allowed. It looks like the call to IsDerivedFrom from IsKindOf is returning false.
Here’s the code I’m using to try to read the geometry:
FILE *pRhinoFile = ON::OpenFile("<path to file>", "rb");
ON_BinaryFile onArchive(ON::archive_mode::read3dm, pRhinoFile);
ON_TextLog errorLog;
ONX_Model onxModel;
model.Read(onArchive, &errorLog);
ON::CloseFile(pRhinoFile);
ONX_ModelComponentIterator onComponentIterator(onxModel, ON_ModelComponent::Type::ModelGeometry);
const ON_ModelComponent* pModelComponent = nullptr;
const ON_Point* pPoint = nullptr;
const ON_Curve* pCurve = nullptr;
const ON_Mesh* pMesh = nullptr;
for (pModelComponent = onComponentIterator.FirstComponent(); nullptr != pModelComponent; pModelComponent = onComponentIterator.NextComponent())
{
const ON_ModelGeometryComponent* pModelGeometry = ON_ModelGeometryComponent::Cast(pModelComponent);
if (nullptr != pModelGeometry)
{
// Get the object attributes
const ON_3dmObjectAttributes *pAttribs = pModelGeometry->Attributes(nullptr);
pPoint = ON_Point::Cast(pModelGeometry->Geometry(nullptr));
if (nullptr != pPoint)
{
// Do stuff...
}
// try reading curves and points
}
}
Attached is a screenshot of the debugger examining the pModelComponent and pModelGeometry variables just after attempting the cast. The structure looks correct. I’m also attaching the results on ONX_Model::Dump and the Rhino .3dm that I’m trying to process.
Any ideas what may be failing here?
This is a standalone application that’s linking with opennurbs-7.11.21285.13001 compiled as a static library.
Thanks,
-Luke
ONX_Model Dump.txt (100.7 KB)
9b16d623-b3a5-49d8-ac4a-9997265f190c.3dm (350.4 KB)