dime  0.9.1
Portable DXF file library
Loading...
Searching...
No Matches
Block.h
1/**************************************************************************\
2 * Copyright (c) Kongsberg Oil & Gas Technologies AS
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * Neither the name of the copyright holder nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31\**************************************************************************/
32
33#ifndef DIME_BLOCK_H
34#define DIME_BLOCK_H
35
36#include <dime/Basic.h>
37#include <dime/entities/Entity.h>
38#include <dime/util/Linear.h>
39
40class dimeInput;
41class dimeMemHandler;
42class dimeModel;
43class dimeOutput;
44
45class DIME_DLL_API dimeBlock : public dimeEntity
46{
47 friend class dimeBlocksSection;
48 friend class dimeEntitiesSection;
49 friend class dimeInsert;
50 friend class dimeModel;
51
52public:
53 dimeBlock(dimeMemHandler * const memhandler);
54 virtual ~dimeBlock();
55
56 const dimeVec3f &getBasePoint() const;
57 void setBasePoint(const dimeVec3f &v);
58 int getNumEntities() const;
59 dimeEntity *getEntity(const int idx);
60 void insertEntity(dimeEntity * const entity, const int idx = -1);
61 void removeEntity(const int idx, const bool deleteIt = true);
62 void fitEntities();
63
64 const char *getName() const;
65 void setName(const char * const name);
66
67 dimeEntity *copy(dimeModel * const model) const;
68 virtual bool getRecord(const int groupcode,
69 dimeParam &param,
70 const int index = 0) const;
71 virtual const char *getEntityName() const;
72
73 virtual bool read(dimeInput * const in);
74 virtual bool write(dimeOutput * const out);
75 virtual int typeId() const;
76 virtual int countRecords() const;
77
78protected:
79 virtual bool handleRecord(const int groupcode,
80 const dimeParam & param,
81 dimeMemHandler * const memhandler);
82
83 virtual void fixReferences(dimeModel * const model);
84 virtual bool traverse(const dimeState * const state,
85 dimeCallback callback,
86 void *userdata);
87
88private:
89 int16 flags;
90 const char *name;
91 dimeVec3f basePoint;
92 dimeArray <dimeEntity*> entities;
93 dimeEntity *endblock;
94 dimeMemHandler *memHandler;
95
96}; // class dimeBlock
97
98inline const dimeVec3f &
100{
101 return this->basePoint;
102}
103
104inline void
106{
107 this->basePoint = v;
108}
109
110inline int
112{
113 return this->entities.count();
114}
115
116inline dimeEntity *
118{
119 assert(idx >= 0 && idx < this->entities.count());
120 return this->entities[idx];
121}
122
123inline const char *
125{
126 return this->name;
127}
128
129inline void
130dimeBlock::setName(const char * const name)
131{
132 this->name = name;
133}
134
135#endif // ! DIME_BLOCK_H
136
int count() const
Definition Array.h:256
virtual int typeId() const =0
The dimeBlock class handles a BLOCK entity.
Definition Block.h:46
dimeEntity * getEntity(const int idx)
Definition Block.h:117
int getNumEntities() const
Definition Block.h:111
const char * getName() const
Definition Block.h:124
void setName(const char *const name)
Definition Block.h:130
void setBasePoint(const dimeVec3f &v)
Definition Block.h:105
const dimeVec3f & getBasePoint() const
Definition Block.h:99
The dimeBlocksSection class handles a BLOCKS section.
Definition BlocksSection.h:40
The dimeEntitiesSection class handles an ENTITIES section.
Definition EntitiesSection.h:40
The dimeEntity class is the superclass of all entity classes.
Definition Entity.h:61
virtual bool getRecord(const int groupcode, dimeParam &param, const int index=0) const
Definition Entity.cpp:715
virtual bool write(dimeOutput *const out)
Definition Entity.cpp:271
virtual void fixReferences(dimeModel *const model)
Definition Entity.cpp:476
virtual bool read(dimeInput *const in)
Definition Entity.cpp:612
virtual const char * getEntityName() const =0
virtual int countRecords() const
Definition Entity.cpp:526
virtual bool handleRecord(const int groupcode, const dimeParam &param, dimeMemHandler *const memhandler)
Definition Entity.cpp:659
virtual dimeEntity * copy(dimeModel *const model) const =0
virtual bool traverse(const dimeState *const state, dimeCallback callback, void *userdata)
Definition Entity.cpp:541
The dimeInput class offers transparent file I/O for DXF and DXB.
Definition Input.h:42
The dimeInsert class handles an INSERT entity.
Definition Insert.h:43
The dimeMemHandler class is a special-purpose memory manager.
Definition MemHandler.h:39
The dimeModel class organizes a model.
Definition Model.h:55
The dimeOutput class handles writing of DXF and DXB files.
Definition Output.h:42
The dimeState class manages various state variables while the model is traversed.
Definition State.h:41
The dimeVec3f class is for containing and operating on a 3D vector / coordinate.
Definition Linear.h:62
The dimeParam class is a union of the different parameter types.
Definition Basic.h:102