dime  0.9.1
Portable DXF file library
Loading...
Searching...
No Matches
dimeBlock Class Reference

The dimeBlock class handles a BLOCK entity. More...

#include <dime/entities/Block.h>

Inheritance diagram for dimeBlock:
dimeEntity dimeRecordHolder dimeBase

Public Member Functions

 dimeBlock (dimeMemHandler *const memhandler)
 
virtual ~dimeBlock ()
 
dimeEntitycopy (dimeModel *const model) const
 
virtual int countRecords () const
 
void fitEntities ()
 
const dimeVec3fgetBasePoint () const
 
dimeEntitygetEntity (const int idx)
 
virtual const char * getEntityName () const
 
const char * getName () const
 
int getNumEntities () const
 
virtual bool getRecord (const int groupcode, dimeParam &param, const int index=0) const
 
void insertEntity (dimeEntity *const entity, const int idx=-1)
 
virtual bool read (dimeInput *const in)
 
void removeEntity (const int idx, const bool deleteIt=true)
 
void setBasePoint (const dimeVec3f &v)
 
void setName (const char *const name)
 
virtual int typeId () const
 
virtual bool write (dimeOutput *const out)
 
- Public Member Functions inherited from dimeEntity
 dimeEntity ()
 
virtual ~dimeEntity ()
 
virtual GeometryType extractGeometry (dimeArray< dimeVec3f > &verts, dimeArray< int > &indices, dimeVec3f &extrusionDir, dxfdouble &thickness)
 
int16 getColorNumber () const
 
int16 getEntityFlags () const
 
const dimeLayergetLayer () const
 
const char * getLayerName () const
 
bool isDeleted () const
 
virtual bool isOfType (const int thetypeid) const
 
bool isTagged () const
 
virtual void print () const
 
void setColorNumber (const int16 c)
 
void setDeleted (const bool onOff=true)
 
void setEntityFlags (const int16 flags)
 
virtual void setLayer (const dimeLayer *const layer)
 
void setTagged (const bool onOff=true)
 
- Public Member Functions inherited from dimeRecordHolder
 dimeRecordHolder (const int separator)
 
virtual ~dimeRecordHolder ()
 
dimeRecordfindRecord (const int groupcode, const int index=0)
 
int getNumRecordsInRecordHolder (void) const
 
dimeRecordgetRecordInRecordHolder (const int idx) const
 
void setIndexedRecord (const int groupcode, const dimeParam &value, const int index, dimeMemHandler *const memhandler=NULL)
 
void setRecord (const int groupcode, const dimeParam &value, dimeMemHandler *const memhandler=NULL)
 
void setRecords (const int *const groupcodes, const dimeParam *const params, const int numrecords, dimeMemHandler *const memhandler=NULL)
 
- Public Member Functions inherited from dimeBase
 dimeBase (void)
 
virtual ~dimeBase ()
 
void operator delete (void *ptr)
 
void * operator new (size_t size, dimeMemHandler *memhandler=NULL, const int alignment=4)
 

Protected Member Functions

virtual void fixReferences (dimeModel *const model)
 
virtual bool handleRecord (const int groupcode, const dimeParam &param, dimeMemHandler *const memhandler)
 
virtual bool traverse (const dimeState *const state, dimeCallback callback, void *userdata)
 
- Protected Member Functions inherited from dimeEntity
bool copyRecords (dimeEntity *const entity, dimeModel *const model) const
 
bool preWrite (dimeOutput *const file)
 
virtual bool shouldWriteRecord (const int groupcode) const
 
- Protected Member Functions inherited from dimeRecordHolder
bool copyRecords (dimeRecordHolder *const rh, dimeMemHandler *const memhandler) const
 

Additional Inherited Members

- Public Types inherited from dimeEntity
enum  GeometryType { NONE , POLYGONS , LINES , POINTS }
 
- Public Types inherited from dimeBase
enum  {
  dimeBaseType = 1 , dimeRecordType , dimeStringRecordType , dimeFloatRecordType ,
  dimeDoubleRecordType , dimeInt8RecordType , dimeInt16RecordType , dimeInt32RecordType ,
  dimeHexRecordType , dimeRecordHolderType , dimeClassType , dimeUnknownClassType ,
  dimeObjectType , dimeUnknownObjectType , dimeEntityType , dimeUnknownEntityType ,
  dimePolylineType , dimeVertexType , dimeFaceEntityType , dimeExtrusionEntityType ,
  dime3DFaceType , dimeSolidType , dimeTraceType , dimeLineType ,
  dimeTextType , dimePointType , dimeBlockType , dimeInsertType ,
  dimeCircleType , dimeArcType , dimeLWPolylineType , dimeEllipseType ,
  dimeSplineType , dimeSectionType , dimeUnknownSectionType , dimeEntitiesSectionType ,
  dimeBlocksSectionType , dimeTablesSectionType , dimeHeaderSectionType , dimeClassesSectionType ,
  dimeObjectsSectionType , dimeTableType , dimeTableEntryType , dimeUnknownTableType ,
  dimeUCSTableType , dimeLayerTableType , dimeLastTypeTag
}
 
- Static Public Member Functions inherited from dimeEntity
static void arbitraryAxis (const dimeVec3f &givenaxis, dimeVec3f &newaxis)
 
static bool copyEntityArray (const dimeEntity *const *const array, const int nument, dimeModel *const model, dimeArray< dimeEntity * > &destarray)
 
static dimeEntity ** copyEntityArray (const dimeEntity *const *const array, int &nument, dimeModel *const model)
 
static dimeEntitycreateEntity (const char *const name, dimeMemHandler *const memhandler=NULL)
 
static void generateUCS (const dimeVec3f &givenaxis, dimeMatrix &m)
 
static bool readEntities (dimeInput *const file, dimeArray< dimeEntity * > &array, const char *const stopat)
 
- Protected Attributes inherited from dimeRecordHolder
int numRecords
 
dimeRecord ** records
 

Detailed Description

The dimeBlock class handles a BLOCK entity.

It cannot strictly be called an entity, as you will only find BLOCKs in the BLOCKS section, not in the ENTITIES section. But BLOCKs share a lot of attributes and functionality with "real" entities, so in DXFLIB, a BLOCK is called an entity.

Constructor & Destructor Documentation

◆ dimeBlock()

dimeBlock::dimeBlock ( dimeMemHandler *const memhandler)

Constructor.

◆ ~dimeBlock()

dimeBlock::~dimeBlock ( )
virtual

Destructor.

Member Function Documentation

◆ copy()

dimeEntity * dimeBlock::copy ( dimeModel *const model) const
virtual

Must be implemented by subclasses to return a copy of the entity. model is the model the new entity should belong to.

Implements dimeEntity.

◆ countRecords()

int dimeBlock::countRecords ( ) const
virtual

Returns the number of records in the record holder. Should be overloaded by subclasses which should count their records, and then call the parent's method. This method is used to precalculate the number of records to be written. Very useful when progress information is needed during write().

Reimplemented from dimeEntity.

◆ fitEntities()

void dimeBlock::fitEntities ( )

Since a growable array is used to hold the entities, it might sometimes use more memory than absolutely needed. Call this method after you have finished modifying a block if you want to free that overhead memory.

◆ fixReferences()

void dimeBlock::fixReferences ( dimeModel *const model)
protectedvirtual

Used to find all forward references.

See also
dimeEntitiesSection::fixReferences().

Reimplemented from dimeEntity.

◆ getBasePoint()

const dimeVec3f & dimeBlock::getBasePoint ( ) const
inline

Returns the base point of this block.

◆ getEntity()

dimeEntity * dimeBlock::getEntity ( const int idx)
inline

Returns the entity at index idx.

See also
dimeBlock::getNumEntities()

◆ getEntityName()

const char * dimeBlock::getEntityName ( ) const
virtual

Must be implemented by subclasses to return the entity name, e.g. POLYLINE, 3DFACE, etc.

Implements dimeEntity.

◆ getName()

const char * dimeBlock::getName ( ) const
inline

Returns the name of this block (used by INSERT to reference the block).

◆ getNumEntities()

int dimeBlock::getNumEntities ( ) const
inline

Returns the number of entities in this block.

◆ getRecord()

bool dimeBlock::getRecord ( const int groupcode,
dimeParam & param,
const int index = 0 ) const
virtual

Will return the value of the record with group code groupcode. false is returned if the record could not be found. Subclasses should overload this method if one or several records are stored in the class. If the group code queried is not stored internally, the subclass should call its parent's method.

Reimplemented from dimeEntity.

◆ handleRecord()

bool dimeBlock::handleRecord ( const int groupcode,
const dimeParam & param,
dimeMemHandler *const memhandler )
protectedvirtual

Must be overloaded by entities that directly support a record type. During dimeRecordHolder::read(), dimeRecordHolder::setRecord and dimeRecordHolder::setRecords, this function is called for every record found, and it is up to the subclass if the record should be stored internally, or if a generic record should be created and stored in this superclass. A subclass should return true when it will handle the record, false otherwise. Default function does nothing, and returns false.

For entities, records with group codes 8 (layer name) and 62 (color number) are automatically handled by the dimeEntity class.

See also
dimeRecordHolder::read()
dimeRecordHolder::setRecord()

Reimplemented from dimeEntity.

◆ insertEntity()

void dimeBlock::insertEntity ( dimeEntity *const entity,
const int idx = -1 )

Inserts an entity in this block at position idx.

◆ read()

bool dimeBlock::read ( dimeInput *const file)
virtual

This method reads a BLOCK entity from file.

Reimplemented from dimeEntity.

◆ removeEntity()

void dimeBlock::removeEntity ( const int idx,
const bool deleteIt = true )

Removes the entity at position idx. If deleteIt is true, and no memory handler is used, the entity will be deleted before returning from this method.

◆ setBasePoint()

void dimeBlock::setBasePoint ( const dimeVec3f & v)
inline

Sets the base point of this entity.

◆ setName()

void dimeBlock::setName ( const char *const name)
inline

Sets the name of this block. name Must be a static char pointer, or some pointer that will not be deleted before the block, as the text string will not be copied. It is best to avoid using this method. Use dimeModel::addBlock() instead.

◆ traverse()

bool dimeBlock::traverse ( const dimeState *const state,
dimeCallback callback,
void * userdata )
protectedvirtual

The traversal function used when dimeModel::traverseEntities() is called. Most entities use this default method, but some entities (INSERT, BUILD) will need to overload it.

Reimplemented from dimeEntity.

◆ typeId()

int dimeBlock::typeId ( ) const
virtual

Must be implemented by all subclasses, and should return an unique id for that class.

Implements dimeBase.

◆ write()

bool dimeBlock::write ( dimeOutput *const file)
virtual

This methods writes a BLOCK entity to file.

Reimplemented from dimeEntity.


The documentation for this class was generated from the following files: