Thankyou Dale, your answers sure is helpful!
I have another question to you, this one about writing to a .3dm.
As stated before, im reading a .3dm file similar to the example_read.cpp file in openNurbs. After that i loop through the ON_Model model and check each object (e.i. model.m_object_table[l].m_object).
for each loop i do the following:
ON_Brep* brep = ON_Brep::New();
bool rc = true;
for (int l = 0; l < brep->m_F.Count(); ++l)
ON_BrepFace& face = brep->m_F[l];
ON_NurbsSurface* nurbssurface = ON_NurbsSurface::Cast(&face);
if( nurbssurface == NULL)
nurbssurface = new ON_NurbsSurface();
int nurb_form_rc = face.GetNurbForm( *nurbssurface );
if (nurb_form_rc == 0)
rc = false;
int si = brep->AddSurface(nurbssurface);
rc = false;
rc = brep->Compact();
const char* filename;
bool ok = false;
filename = "My_file.3dm";
FILE* fp = ON::OpenFile( filename, "wb" );
const ON_Brep* newconstBrep = ON_Brep::New();
std::cout << i << std::endl;
if (brep->IsValid (&error_log) )
ON_BinaryFile archive(ON::write3dm, fp);
ok = ON_WriteOneObjectArchive( archive, 0, *ON_Object::Cast(newconstBrep) );
std::cout << "success! " << std::endl;
ON::CloseFile( fp );
So basically i want to read a .3dm file, convert all faces in each brep to nurbfaces, and then save this as a new .3dm file.
My problems atm is the following:
- in some occasions i get errormessages from the error_log saying “ON_Brep has no faces, edges, or vertices”
- the bigger problem is that (as i understand it) a complicated geometry can consist of several objects/breps and that i atm just looping through each object/brep and saveing that to the file. E.i. i would rather like to save all objects/breps in a .3dm file. My initial thought is that i should be able to do the revese process from reading the file. When reading the file i save all content of the file in an ONX_Model. Would the right way to go about saveing on a .3dm file be to save each constructed Brep/object on a new ONX_Model and then write this ONX_Model into a .3dm file? If yes, could you point me in the right direction for how to do this? (have tried but haveing trubble)
Thanks again and thanks in advance for your answer!