Hello friends! Im trying to read a .3dm file, however, not all the objects are classified as Breps. What other kind of objects does excist? Below is part of the code im using to read the .3dm file
ONX_Model model;
// open file containing opennurbs archive
FILE* archive_fp = ON::OpenFile( filename.c_str(), “rb”);
if ( !archive_fp )
std::cout << filename << “: Unable to open file.\n”;
else {
// create archive object from file pointer
ON_BinaryFile archive( ON::read3dm, archive_fp );
// read the contents of the file into "model"
bool rc = model.Read( archive);
// close the file
ON::CloseFile( archive_fp );
// print diagnostic
if ( rc )
std::cout << "Successfully read.\n";
else
std::cout << "Errors during reading.\n";
// see if everything is in good shape
if ( model.IsValid() )
std::cout << "Model is valid.\n";
else
std::cout << "Model is not valid.\n";
std::cout << "The count is " << model.m_object_table.Count() << std::endl;
for (int i = 0; i < model.m_object_table.Count(); ++i) {
if(ON_Brep::Cast(model.m_object_table[i].m_object))
{
extractBrep(model.m_object_table[i].m_object, brep);
}
else if (ON_Geometry::Cast(model.m_object_table[i].m_object))
{
const ON_Geometry* pGeometry = ON_Geometry::Cast(model.m_object_table[i].m_object);
if(ON_Brep::Cast(pGeometry))
{
extractBrep(pGeometry, brep);
}
else if ( pGeometry->HasBrepForm() )
{
ON_Brep* brep2 = pGeometry->BrepForm();
std::cout << "Got a thing that has a Brep form." << std::endl;
extractBrep(brep2, brep);
delete brep2;
}
else if(ON_Surface::Cast(pGeometry))
{
std::cout << "Found surface that was not brep 1" << std::endl;
}
else std::cout << "Didnt have Brep form." << std::endl;
}
else if(ON_Surface::Cast(model.m_object_table[i].m_object))
{
std::cout << "Found surface that was not brep 2" << std::endl;
}
else
{
std::cout << "neither surface nor brep" << std::endl;
}
}
std::cout << "Found " << brep.size() << " BREP objects of at least " << model.m_object_table.Count() << " possible." << std::endl;