DXF entity database. More...
#include <mydxfentities.hpp>
Public Member Functions | |
MyDXFEntities (class MyDXFFile *dxf) | |
Construct empty entities database. | |
MyDXFEntities (class MyDXFFile *dxf, MyDXFEntities *ent, MyDXFEntitySelection *sel) | |
Construct new entities containing copies of selected intities in ent. | |
MyDXFEntities (class MyDXFFile *dxf, bool reading_blocks) | |
Construct entities database by reading from DXF file. | |
~MyDXFEntities () | |
Destructor. | |
void | write (class MyDXFFile *dxf, std::ofstream &ostr) |
Write entities section of dxf file to stream. | |
void | write_entities (class MyDXFFile *dxf, std::ofstream &ostr) |
Write a list of entities to stream. | |
uint32_t | size () const |
Return number of entities. | |
const MyDXFEntity * | get_entity (uint32_t a) const |
Return const pointer to entity a. | |
MyDXFEntity * | get_entity (uint32_t a) |
Return pointer to entity a. | |
void | add_entity (MyDXFEntity *e) |
Add entity to list. | |
MyDXFEntitySelection * | selection_all (void) const |
Make a new selection containg all entities from database. | |
MyDXFEntitySelection * | selection_layer (const std::string &layername) const |
Make a new selection containg entities from named layer. | |
MyDXFEntitySelection * | selection_type (EntityType type) const |
Make a new selection containg entities of given type. | |
MyDXFEntitySelection * | selection_path_loop (MyDXFEntitySelection *selection, double eps=1.0e-6) |
Build complete loops. | |
bool | geom_same (uint32_t a, uint32_t b, double eps=1.0e-6) const |
Check if two entities are geometrically same. | |
bool | inside_loop (MyDXFEntitySelection *selection, double x, double y, double eps=1.0e-6) |
void | plot (const MyDXFEntitySelection *selection, const class MyDXFFile *dxf, cairo_t *cairo, const Transformation *t, const double range[4]) const |
Plot selected entities with cairo. | |
void | get_bbox (const MyDXFEntitySelection *selection, Vec3D &min, Vec3D &max, const class MyDXFFile *dxf, const Transformation *t) const |
Get bounding box containing all entities in selection. | |
void | scale (MyDXFEntitySelection *selection, class MyDXFFile *dxf, double s) |
Scale selected entities by factor s. | |
void | translate (MyDXFEntitySelection *selection, class MyDXFFile *dxf, const Vec3D &dx) |
Translate selected entities by dx. | |
void | remove (MyDXFEntitySelection *selection) |
Remove selected entities. | |
void | explode (MyDXFEntitySelection *selection, class MyDXFFile *dxf) |
Explode selected insert entities. | |
void | explode (MyDXFEntities *ent, class MyDXFFile *dxf, const Transformation *t) const |
Explode all entities to ent. | |
void | debug_print (std::ostream &os) const |
Print debugging information to os. |
DXF entity database.
A database of entities. Also responsible for reading entities from a DXF file. All supported entities are saved to database. All others are ignored.
MyDXFEntities::MyDXFEntities | ( | class MyDXFFile * | dxf | ) |
Construct empty entities database.
MyDXFEntities::MyDXFEntities | ( | class MyDXFFile * | dxf, |
MyDXFEntities * | ent, | ||
MyDXFEntitySelection * | sel | ||
) |
Construct new entities containing copies of selected intities in ent.
MyDXFEntities::MyDXFEntities | ( | class MyDXFFile * | dxf, |
bool | reading_blocks | ||
) |
Construct entities database by reading from DXF file.
Called with reading_block = true if called from inside BLOCKS section and reading_block = false if called inside ENTITIES section.
Destructor.
void MyDXFEntities::add_entity | ( | MyDXFEntity * | e | ) | [inline] |
Add entity to list.
No copy of entity is made. The pointer is saved to the database.
void MyDXFEntities::debug_print | ( | std::ostream & | os | ) | const |
Print debugging information to os.
void MyDXFEntities::explode | ( | MyDXFEntitySelection * | selection, |
class MyDXFFile * | dxf | ||
) |
Explode selected insert entities.
The insert entities are expoded to contain just primitive entities with no dependencies to blocks. Selection can be a NULL pointer to explode all entities.
void MyDXFEntities::explode | ( | MyDXFEntities * | ent, |
class MyDXFFile * | dxf, | ||
const Transformation * | t | ||
) | const |
Explode all entities to ent.
Explode and add all entities into ent using transformation t.
bool MyDXFEntities::geom_same | ( | uint32_t | a, |
uint32_t | b, | ||
double | eps = 1.0e-6 |
||
) | const |
Check if two entities are geometrically same.
Checks if entity a is the geometrically same as entity b within error limit eps.
void MyDXFEntities::get_bbox | ( | const MyDXFEntitySelection * | selection, |
Vec3D & | min, | ||
Vec3D & | max, | ||
const class MyDXFFile * | dxf, | ||
const Transformation * | t | ||
) | const |
Get bounding box containing all entities in selection.
const MyDXFEntity* MyDXFEntities::get_entity | ( | uint32_t | a | ) | const [inline] |
Return const pointer to entity a.
MyDXFEntity* MyDXFEntities::get_entity | ( | uint32_t | a | ) | [inline] |
Return pointer to entity a.
bool MyDXFEntities::inside_loop | ( | MyDXFEntitySelection * | selection, |
double | x, | ||
double | y, | ||
double | eps = 1.0e-6 |
||
) |
void MyDXFEntities::plot | ( | const MyDXFEntitySelection * | selection, |
const class MyDXFFile * | dxf, | ||
cairo_t * | cairo, | ||
const Transformation * | t, | ||
const double | range[4] | ||
) | const |
Plot selected entities with cairo.
Plot the entities using the transformation t from the object space to cairo coordinates. The visible range is specified by range (xmin,ymin,xmax,ymax) in cairo coordinates.
Selection can be a NULL pointer to plot all entities.
void MyDXFEntities::remove | ( | MyDXFEntitySelection * | selection | ) |
Remove selected entities.
Selection can be a NULL pointer to remove all entities. The selection is invalid after this operation and should not be used further. Also all other selections are invalidated by this operation because entity indices change.
void MyDXFEntities::scale | ( | MyDXFEntitySelection * | selection, |
class MyDXFFile * | dxf, | ||
double | s | ||
) |
Scale selected entities by factor s.
Selection can be a NULL pointer to plot all entities.
MyDXFEntitySelection* MyDXFEntities::selection_all | ( | void | ) | const |
Make a new selection containg all entities from database.
MyDXFEntitySelection* MyDXFEntities::selection_layer | ( | const std::string & | layername | ) | const |
Make a new selection containg entities from named layer.
MyDXFEntitySelection* MyDXFEntities::selection_path_loop | ( | MyDXFEntitySelection * | selection, |
double | eps = 1.0e-6 |
||
) |
Build complete loops.
Make a new subselection of a selection. The new selection will contain only objects, which make up one or several complete loops. Ending point of one entity is ensured to be exactly the starting point of another entity. Errors of the size eps are accepted and fixed between end-to-end matching.
MyDXFEntitySelection* MyDXFEntities::selection_type | ( | EntityType | type | ) | const |
Make a new selection containg entities of given type.
uint32_t MyDXFEntities::size | ( | void | ) | const [inline] |
Return number of entities.
void MyDXFEntities::translate | ( | MyDXFEntitySelection * | selection, |
class MyDXFFile * | dxf, | ||
const Vec3D & | dx | ||
) |
Translate selected entities by dx.
void MyDXFEntities::write | ( | class MyDXFFile * | dxf, |
std::ofstream & | ostr | ||
) |
Write entities section of dxf file to stream.
void MyDXFEntities::write_entities | ( | class MyDXFFile * | dxf, |
std::ofstream & | ostr | ||
) |
Write a list of entities to stream.
This function only writes the entities withing the object. It can be called for writing the entities section or a block.