When I open a particular Dxf file in LibreCAD, the command line dialog box in libreCAD says :
Invalid objects removed : 1
I want to detect this invalid object in my dxf file and remove it. When does an object become invalid? What does an invalid object mean?
Since I didn't receive any answers overe here, I decided to dig into the libreCAD source code, and found this in rs_graphic.cpp :
/**
* Removes invalid objects.
* @return how many objects were removed
*/
int RS_Graphic::clean()
{
// author: ravas
int how_many = 0;
foreach (RS_Entity* e, entities)
{
if (e->getMin().x > e->getMax().x
|| e->getMin().y > e->getMax().y
|| e->getMin().x > RS_MAXDOUBLE
|| e->getMax().x > RS_MAXDOUBLE
|| e->getMin().x < RS_MINDOUBLE
|| e->getMax().x < RS_MINDOUBLE
|| e->getMin().y > RS_MAXDOUBLE
|| e->getMax().y > RS_MAXDOUBLE
|| e->getMin().y < RS_MINDOUBLE
|| e->getMax().y < RS_MINDOUBLE)
{
removeEntity(e);
how_many += 1;
}
}
The above code is self-explanatory and I hope this helps anyone who wonders the same question in future.